:root {
  --black-01: rgba(0, 0, 0, 0.01);
  --black-03: rgba(0, 0, 0, 0.03);
  --black-05: rgba(0, 0, 0, 0.05);
  --black-06: rgba(0, 0, 0, 0.06);
  --black-08: rgba(0, 0, 0, 0.08);
  --black-25: rgba(0, 0, 0, 0.25);
  --white-32: rgba(255, 255, 255, 0.32);

  --white: #ffffff;
  --gray-100: #f3f3f3;
  --gray-200: #dddddd;
  --gray-300: #a8a8a8;
  --gray-400: #858585;
  --gray-500: #666666;
  --gray-600: #404040;
  --gray-700: #313131;
  --black: #000000;

  --background-color: var(--gray-100);

  --background: #f3f3f3;
  --panel: #ffffff;
  --cta: #000000;
  --cta-text: #ffffff;
}

@media (prefers-color-scheme: dark) {
  :root {
    --white: #000000;
    --gray-100: #121212;
    --gray-200: #1e1e1e;
    --gray-300: #2a2a2a;
    --gray-400: #444444;
    --gray-500: #666666;
    --gray-600: #888888;
    --gray-700: #aaaaaa;
    --black: #ffffff;

    --black-01: rgba(255, 255, 255, 0.01);
    --black-03: rgba(255, 255, 255, 0.03);
    --black-05: rgba(255, 255, 255, 0.05);
    --black-06: rgba(255, 255, 255, 0.06);
    --black-08: rgba(255, 255, 255, 0.08);
    --black-25: rgba(255, 255, 255, 0.25);
    --white-32: rgba(0, 0, 0, 0.32);

    --background-color: var(--white);

    --background: #000000;
    --panel: #242424;
    --cta: #000000;
    --cta-text: #ffffff;
  }
  .header-bar {
    background: var(--white);
  }
}

*, *::before, *::after {
  box-sizing: border-box;
}
body {
  font-family: -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--background);
  margin: 0;
  padding: 0;
  padding-bottom: env(safe-area-inset-bottom);
  display: flex;
  flex-direction: column;
  background-color: var(--background);
}

html, body {
  background-color: var(--background);
}

.container {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 112px 16px 9rem; /* Extra bottom padding for Resolve button */
  max-width: 800px;
  margin-left: auto;
  margin-right: auto;
  width: 100%;
  min-height: 100dvh; /* Respect mobile browser UI */
  box-sizing: border-box;
  height: 100vh;
  overflow-y: auto;
  overflow: hidden;
}

h1 {
  font-size: 1.8rem;
  letter-spacing: 2px;
  color: var(--black);
}

.description {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: var(--gray-300);
  text-align: center;
  padding: 0 16px;
  z-index: 0;
  font-size: 1rem;
}

#introText {
  transition: opacity 0.3s ease;
}

.input-row {
  display: flex;
  gap: 0.5rem;
  margin: 1rem 0;
  width: 100%;
}

.item-list {
  background: var(--panel);
  border-radius: 8px;
  overflow-y: auto;
  display: none;
  flex-direction: column;
  padding-bottom: 0;
  padding-left: 0px;
}

.scrollable-list {
  overflow-y: auto;
  max-height: 40vh;
  display: flex;
  flex-direction: column;
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  box-sizing: border-box;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 32px);
  position: relative;
}

.input-wrapper input {
  flex: 1;
  display: block;
  width: 100%;
  box-sizing: border-box;
  flex-grow: 1;
}

#itemInput {
  width: 100%;
  padding: 0.75rem;
  /* margin-left: 16px;
  margin-right: 16px; */
  border-radius: 8px;
  border: 1px solid var(--gray-200);
  font-size: 16px;
  box-sizing: border-box;
  background-color: var(--white);
  color: var(--black);
}

#addButton {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  padding: 8px;
  background: var(--black);
  color: var(--white);
  border: none;
  border-radius: 999px;
  display: none;
  cursor: pointer;
}

#addButton svg {
  display: block;
  margin: auto;
}

.input-wrapper.show-add-button #addButton {
  display: inline-block;
}

.resolve-button, #reResolveButton {
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  padding: 32px 8px;
  gap: 8px;
  width: calc(100% - 32px);
  max-width: 800px;
  margin: 0 auto;
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 24px;
  height: 64px;
  background: var(--black);
box-shadow: 0px -2px 0px 0px rgba(255, 255, 255, 0.08) inset, 0px -4px 4px 0px rgba(255, 255, 255, 0.16) inset, 0px 2px 0px 0px rgba(255, 255, 255, 0.16) inset, 0px 4px 8px 0px rgba(255, 255, 255, 0.32) inset, 0px 146px 41px 0px rgba(0, 0, 0, 0.00), 0px 94px 37px 0px rgba(0, 0, 0, 0.01), 0px 53px 32px 0px rgba(0, 0, 0, 0.03), 0px 23px 23px 0px rgba(0, 0, 0, 0.05), 0px 6px 13px 0px rgba(0, 0, 0, 0.06);
  border: none;
  border-radius: 16px;
  color: var(--white);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  z-index: 10;
}

.resolve-button:hover, #reResolveButton:hover {
  background: var(--gray-700);
  transition: background 0.2s ease;
}

.resolve-button:active, #reResolveButton:active {
  background: var(--gray-600);
  transition: background 0.2s ease;
}

.item-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 0.75rem;
  padding-bottom: 0.75rem;
  padding-left: 0;
  padding-right: 0;
  border-bottom: 1px solid var(--gray-100);
  position: relative;
  overflow: hidden;
  background: var(--panel);
  border-radius: 0;
  touch-action: pan-y;
  color: var(--black);
  will-change: transform;
  transform-style: preserve-3d;
  backface-visibility: hidden;
}

.item-list li:last-child {
  border-bottom: none;
}

.item-list li .remove-btn {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 80px;
  background: var(--black);
  color: var(--white);
  border: none;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
  transform: translateX(100%);
  z-index: 1;
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.item-list li button {
  background: none;
  border: none;
  color: red;
  font-weight: bold;
  font-size: 1rem;
  cursor: pointer;
}

.result-box {
  padding: 2rem;
  background: var(--panel);
  border-radius: 16px;
  font-size: 1.5rem;
  font-weight: bold;
  color: var(--black);
  box-shadow: 0px 1px 4px 0px var(--black-08);
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
  width: 100%;
  max-width: 800px;
  height: calc(100dvh - 112px - 64px - 48px); /* header + button + 16px + extra spacing */
  margin-bottom: 16px;
  box-sizing: border-box;
  position: relative;
  overflow-y: auto;
}

.hidden {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  height: 0 !important;
  overflow: hidden !important;
}

.item-content {
  background: var(--panel);
  padding-top: 0.75rem;
  padding-bottom: 0.75rem;
  padding-left: 16px;
  padding-right: 16px;
  width: 100%;
  box-sizing: border-box;
  position: relative;
  z-index: 1;
  margin-right: 0;
  color: var(--black);
}

.item-list.visible {
  display: flex;
}

.content-panel {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 32px);
  max-width: 800px;
  bottom: 104px;
  top: auto;
  display: flex;
  flex-direction: column;
  border-radius: 16px;
  overflow: hidden;
  z-index: 9;
  background: var(--panel);
  box-shadow: 0px 1px 4px var(--black-08);
  overflow-y: auto;
  transition: height 0.3s ease;
  overflow: hidden;
}

.content-panel.expand {
  max-height: 50vh;
}

.resolve-button.disabled {
  background-color: var(--black);
  cursor: not-allowed;
  color: var(--gray-400);
}

.item-list:not(:empty) {
  display: flex;
}

.result-visible .item-list,
.result-visible .input-wrapper,
.result-visible .content-panel {
  display: none !important;
}

.result-visible .header-button {
  display: inline-flex;
  opacity: 1;
}

#confetti-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100% !important;
  height: 100% !important;
  pointer-events: none;
  z-index: 9999;
  display: block !important;
  opacity: 1 !important;
}

.item-slid .remove-btn {
  opacity: 1;
  transform: translateX(0);
}

.header-button {
  padding: 8px 16px;
  gap: 8px;
  border-radius: 4px;
  border: 1px solid var(--gray-200);
  background-color: var(--white);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-align: center;
  white-space: nowrap;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  margin: 0;
  z-index: 11;
  display: none;
  color: var(--black);
  opacity: 0;
  transition: opacity 0.4s ease 0.5s;
}

.header-button:hover {
  background-color: var(--gray-100);
  transition: background-color 0.2s ease;
}

.header-button:active {
  background-color: var(--gray-200);
  transition: background-color 0.2s ease;
}

.result-visible .header-button.reset {
  display: inline-flex;
  opacity: 1;
}

.content-visible .header-button.reset {
  display: inline-flex;
  opacity: 1;
}

.header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  left: 0;
  right: 0;
  height: 112px;
  padding: 16px;
  max-width: 800px;
  width: 100%;
  box-sizing: border-box;
  z-index: 10;
  background: var(--background);
  margin: 0 auto;
}

.header-button.back {
  order: 1;
}

.header-title {
  order: 2;
  flex: 1;
  text-align: center;
  font-weight: bold;
  font-size: 1.5rem;
  color: var(--black)
}

/* Reset button: hidden by default, shown in .result-visible and .content-visible states */
.header-button.reset {
  order: 3;
  display: none;
}

.result-visible .header-button.reset {
  display: inline-flex;
}

.content-visible .header-button.reset {
  display: inline-flex;
}

.header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 112px;
  padding: 16px;
  max-width: 800px;
  width: 100%;
  box-sizing: border-box;
  z-index: 10;
  background: var(--background);
  margin: 0 auto;
}

.header-title {
  flex: 1;
  text-align: center;
  font-weight: bold;
  font-size: 1.5rem;
}
@media (max-height: 500px) {
  .content-panel {
    max-height: 30vh;
  }

  .container {
    overflow-y: auto;
  }
}
@keyframes slideUp {
  from {
    transform: translateY(16px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.item-list li {
  transition: transform 0.3s ease-out, opacity 0.3s ease-out;
}

.item-list li.animate-slide-up {
  animation: slideUp 0.3s ease-out;
}