:root {
  color-scheme: light;
  --bg: #f0f5e7;
  --panel: rgba(255, 255, 245, 0.94);
  --brown: #87643c;
  --brown-dark: #6e4f2c;
  --brown-light: #b4966e;
  --cream: #f0f5e7;
  --text: #5a4024;
  --muted: #87643c;
  --border: rgba(135, 100, 60, 0.28);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Lato", "Noto Sans TC", "Segoe UI", Georgia, serif;
  background-color: var(--bg);
  background-image: url("assets/bg.jpg");
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Side Menu */
.side-menu {
  position: fixed;
  top: 1.25rem;
  left: 1.25rem;
  z-index: 30;
  width: 200px;
  background: var(--panel);
  backdrop-filter: blur(10px);
  border-radius: 1.25rem;
  padding: 1rem;
  border: 1.5px solid var(--brown);
  box-shadow: 0 14px 34px rgba(90, 64, 36, 0.14);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.side-menu-header {
  text-align: center;
  padding-bottom: 0.45rem;
  border-bottom: 1px solid var(--border);
}

.side-menu-title {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--brown);
}

.side-menu-nav {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  padding: 0.65rem 0.9rem;
  border-radius: 0.85rem;
  border: 1px solid transparent;
  background: transparent;
  color: var(--brown);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  transition: background 150ms ease, color 150ms ease, transform 120ms ease,
    border-color 150ms ease;
}

.menu-item:hover {
  background: rgba(135, 100, 60, 0.1);
  border-color: var(--border);
}

.menu-item.active {
  background: var(--brown);
  color: var(--cream);
  box-shadow: 0 6px 14px rgba(135, 100, 60, 0.25);
}

.menu-icon {
  font-size: 1.15rem;
  line-height: 1;
}

.control-panel {
  margin-top: 0.35rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  width: 280px;
  max-width: calc(100vw - 3rem);
  transition: max-height 200ms ease, opacity 180ms ease;
}

.control-panel.collapsed {
  display: none;
}

.control-panel h2 {
  margin: 0 0 0.65rem;
  font-size: 1rem;
  color: var(--brown);
}

.entry-form {
  display: flex;
  align-items: stretch;
  gap: 0.45rem;
  margin-bottom: 0.75rem;
}

.entry-form input {
  flex: 1;
  min-width: 0;
  padding: 0.5rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fffef9;
  color: var(--text);
  font-size: 0.88rem;
}

.entry-form button {
  padding: 0 1rem;
  border-radius: 999px;
  border: none;
  font-size: 0.88rem;
  font-weight: 600;
  background: var(--brown);
  color: var(--cream);
  cursor: pointer;
  transition: background 150ms ease;
  flex-shrink: 0;
}

.entry-form button:hover,
.entry-form button:focus {
  background: var(--brown-dark);
}

.entry-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.4rem;
  max-height: 300px;
  overflow-y: auto;
}

.entry-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.45rem 0.7rem;
  border-radius: 0.65rem;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.75);
  font-size: 0.88rem;
}

.entry-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-weight: 600;
  color: var(--brown);
}

.color-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1px solid rgba(135, 100, 60, 0.4);
}

.entry-actions {
  display: flex;
  align-items: center;
}

.entry-actions button {
  border: none;
  background: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.8rem;
}

.entry-actions button:hover,
.entry-actions button:focus {
  color: #b91c1c;
}

.page-header {
  padding: 1.25rem 1.5rem 0.25rem;
  text-align: center;
  width: 100%;
  max-width: 560px;
}

.header-logo {
  width: 100%;
  max-width: 420px;
  height: auto;
  display: block;
  margin: 0 auto -1.6rem;
  pointer-events: none;
  user-select: none;
}

.layout {
  width: 100%;
  max-width: 1100px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 2rem;
  padding: 0 1.5rem 2.5rem;
}

.wheel-panel,
.gacha-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  max-width: 600px;
}

.hidden {
  display: none !important;
}

.wheel-stage,
.gacha-stage {
  position: relative;
  width: 100%;
  max-width: 560px;
  display: flex;
  justify-content: center;
  align-items: center;
}

#wheel {
  width: 100%;
  max-width: 560px;
  height: auto;
  cursor: pointer;
  filter: drop-shadow(0 12px 28px rgba(135, 100, 60, 0.12));
}

#gacha-canvas {
  width: 100%;
  max-width: 470px;
  height: auto;
  cursor: pointer;
  filter: drop-shadow(0 14px 30px rgba(135, 100, 60, 0.16));
}

.spin-btn {
  margin-top: -1.6rem;
  z-index: 5;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 0.85rem 3.2rem;
  border-radius: 999px;
  border: 1.5px solid #6e4f2c;
  font-family: Georgia, "Times New Roman", "Noto Sans TC", serif;
  font-size: 1.85rem;
  font-weight: 400;
  letter-spacing: 0.04em;
  background: linear-gradient(180deg, #87643c 0%, #755430 100%);
  color: #f4f6eb;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(110, 79, 44, 0.28);
  transition: transform 150ms ease, box-shadow 150ms ease, filter 150ms ease;
}

.gacha-btn {
  margin-top: -0.6rem;
  font-size: 1.55rem;
  padding: 0.8rem 2.8rem;
}

.spin-btn .star-icon {
  font-size: 1.35rem;
  opacity: 0.92;
}

.spin-btn:hover:not([disabled]),
.spin-btn:focus:not([disabled]) {
  transform: translateY(-2px);
  box-shadow: 0 14px 30px rgba(110, 79, 44, 0.38);
  filter: brightness(1.05);
}

.spin-btn[disabled] {
  opacity: 0.65;
  cursor: not-allowed;
}

.result {
  min-height: 1.8rem;
  margin: 0.35rem 0 0;
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--brown);
  letter-spacing: 0.03em;
}

.modal {
  position: fixed;
  inset: 0;
  display: block;
  z-index: 40;
}

.modal.hidden {
  pointer-events: none;
  opacity: 0;
}

.modal:not(.hidden) {
  opacity: 1;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(60, 42, 24, 0.45);
}

.modal-body {
  position: absolute;
  z-index: 1;
  width: min(340px, 90vw);
  background: var(--panel);
  border-radius: 1rem;
  padding: 1.25rem 1.5rem 1.5rem;
  border: 1px solid var(--border);
  box-shadow: 0 18px 48px rgba(60, 42, 24, 0.3);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Winner Modal styled in OOOPEN Lab Life Energy Wheel theme */
.winner-modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  transition: opacity 220ms ease;
}

.winner-modal.hidden {
  display: flex !important;
  pointer-events: none;
  opacity: 0;
}

.winner-modal:not(.hidden) {
  opacity: 1;
}

.winner-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(74, 52, 30, 0.52);
  backdrop-filter: blur(4px);
}

.winner-card {
  position: relative;
  z-index: 1;
  width: min(460px, 92vw);
  background-color: #f0f5e7;
  background-image: url("assets/bg.jpg");
  background-size: cover;
  background-position: center;
  border-radius: 1.75rem;
  padding: 2.4rem 2rem 2.1rem;
  text-align: center;
  border: 2px solid #87643c;
  box-shadow: 0 28px 64px rgba(74, 52, 30, 0.35),
    inset 0 0 0 6px rgba(240, 245, 231, 0.65),
    inset 0 0 0 7.5px rgba(135, 100, 60, 0.45);
  transform: scale(0.8) translateY(16px);
  transition: transform 280ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.winner-modal:not(.hidden) .winner-card {
  transform: scale(1) translateY(0);
}

.winner-subtitle {
  margin: 0;
  font-family: Georgia, "Times New Roman", "Noto Sans TC", serif;
  font-size: 1.35rem;
  font-weight: 600;
  color: #87643c;
  letter-spacing: 0.04em;
}

.winner-subtitle span {
  border-bottom: 1.5px solid #87643c;
  padding-bottom: 0.25rem;
}

.winner-star-divider {
  margin: 0.85rem 0;
  color: #87643c;
  font-size: 1.35rem;
  letter-spacing: 0.25em;
}

.winner-number {
  margin: 0.35rem 0;
  padding: 1.05rem 1.2rem;
  border-radius: 1.1rem;
  background: rgba(255, 254, 242, 0.82);
  border: 1.5px solid #87643c;
  font-family: Georgia, "Lato", serif;
  font-size: 2.55rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: #87643c;
  word-break: break-all;
  box-shadow: 0 6px 18px rgba(135, 100, 60, 0.12);
}

.winner-Desc {
  margin: 0.35rem 0 1.45rem;
  font-size: 1rem;
  font-style: italic;
  color: #87643c;
}

.winner-actions {
  display: flex;
  justify-content: center;
}

.winner-close-btn {
  padding: 0.8rem 2.8rem;
  border-radius: 999px;
  border: 1px solid #6e4f2c;
  font-family: Georgia, "Noto Sans TC", serif;
  font-size: 1.15rem;
  font-weight: 600;
  color: #f0f5e7;
  background: #87643c;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(135, 100, 60, 0.28);
  transition: transform 150ms ease, background 150ms ease;
}

.winner-close-btn:hover,
.winner-close-btn:focus {
  background: #6e4f2c;
  transform: translateY(-1px);
}

@media (max-width: 900px) {
  .side-menu {
    position: static;
    width: min(460px, 92vw);
    margin-top: 0.75rem;
  }

  .side-menu-nav {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .menu-item {
    flex: 1;
    justify-content: center;
  }
}
