@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:wght@500;600;700&family=Outfit:wght@400;500;600;700&display=swap');

:root {
  --ink: #f3ebe0;
  --muted: #b8a894;
  --panel: rgba(18, 14, 12, 0.72);
  --panel-solid: #1a1512;
  --line: rgba(196, 165, 116, 0.35);
  --accent: #c4a574;
  --accent-hot: #e0c090;
  --danger: #d96b5c;
  --ok: #6dbf8c;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  --radius: 14px;
  --font-display: 'Cormorant Garamond', Georgia, serif;
  --font-ui: 'Outfit', system-ui, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #12100e;
  color: var(--ink);
  font-family: var(--font-ui);
  user-select: none;
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
}

#c {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  cursor: grab;
}

#c:active {
  cursor: grabbing;
}

body.touch-device .btn,
body.touch-device .chip,
body.touch-device .btn-icon {
  min-height: 40px;
}

#ui {
  pointer-events: none;
  position: absolute;
  inset: 0;
  z-index: 10;
}

/* Only interactive chrome receives clicks — never the full-screen shells */
.menu,
.overlay,
.status-pill,
.top-actions,
.side-panel:not(.collapsed),
.bottom-bar,
.thinking,
.btn,
.chip,
.toggle,
.promo-choices button {
  pointer-events: auto;
}

.hud,
.top-bar {
  pointer-events: none;
}

/* —— Menu —— */
.menu {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: clamp(16px, 4vh, 40px) 20px 8vh;
  background: linear-gradient(
    180deg,
    rgba(10, 8, 7, 0.15) 0%,
    rgba(10, 8, 7, 0.35) 45%,
    rgba(10, 8, 7, 0.78) 100%
  );
}

.menu-card {
  width: min(420px, 100%);
  text-align: center;
  animation: rise 0.7s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(24px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.brand {
  font-family: var(--font-display);
  font-size: clamp(2.8rem, 8vw, 4.2rem);
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 0.95;
  color: var(--ink);
  text-shadow: 0 4px 30px rgba(0, 0, 0, 0.6);
}

.brand span {
  display: block;
  font-size: 0.38em;
  letter-spacing: 0.35em;
  text-transform: uppercase;
  color: var(--accent);
  font-family: var(--font-ui);
  font-weight: 500;
  margin-bottom: 0.35em;
}

.tagline {
  margin: 0.75rem 0 1.6rem;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 400;
}

.menu-actions {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 0.95rem;
  padding: 0.9rem 1.2rem;
  border-radius: 999px;
  cursor: pointer;
  backdrop-filter: blur(12px);
  transition:
    background 0.2s,
    border-color 0.2s,
    transform 0.15s;
}

.btn:hover {
  background: rgba(40, 32, 26, 0.9);
  border-color: var(--accent);
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: linear-gradient(135deg, #c4a574, #a8864f);
  color: #1a120c;
  border-color: transparent;
}

.btn-primary:hover {
  background: linear-gradient(135deg, #e0c090, #c4a574);
  border-color: transparent;
}

.btn-ghost {
  background: transparent;
}

.btn-sm {
  padding: 0.5rem 0.85rem;
  font-size: 0.8rem;
  border-radius: 10px;
}

.btn-icon {
  width: 40px;
  height: 40px;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 12px;
  font-size: 1rem;
}

.difficulty {
  display: flex;
  gap: 0.4rem;
  justify-content: center;
  margin-top: 0.4rem;
}

.difficulty .chip {
  flex: 1;
  padding: 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.difficulty .chip.active {
  background: rgba(196, 165, 116, 0.2);
  color: var(--accent-hot);
  border-color: var(--accent);
}

.hidden {
  display: none !important;
}

/* —— HUD —— */
.hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.hud > * {
  pointer-events: auto;
}

.top-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: max(12px, env(safe-area-inset-top)) 14px 0;
}

.status-pill {
  background: var(--panel);
  border: 1px solid var(--line);
  backdrop-filter: blur(14px);
  border-radius: 16px;
  padding: 0.65rem 1rem;
  box-shadow: var(--shadow);
  min-width: 140px;
}

.status-pill .label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.status-pill .value {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 600;
  margin-top: 0.1rem;
}

.status-pill .value.check {
  color: var(--danger);
}

.status-pill .meta {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.15rem;
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  justify-content: flex-end;
  max-width: 52vw;
}

.side-panel {
  position: absolute;
  top: 90px;
  right: 14px;
  width: min(260px, 42vw);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
  overflow: hidden;
  max-height: calc(100vh - 120px);
  display: flex;
  flex-direction: column;
  transition: transform 0.3s ease, opacity 0.3s;
  z-index: 5;
}

.side-panel.collapsed,
.side-panel.collapsed * {
  pointer-events: none !important;
}

.side-panel.collapsed {
  transform: translateX(calc(100% + 20px));
  opacity: 0;
}

.side-panel .panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.7rem 0.85rem;
  border-bottom: 1px solid var(--line);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.side-panel .panel-body {
  padding: 0.75rem 0.85rem;
  overflow-y: auto;
  flex: 1;
}

.captured {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem;
  min-height: 1.4rem;
  margin-bottom: 0.75rem;
  font-size: 1.05rem;
  letter-spacing: 0.02em;
}

.captured .row-label {
  width: 100%;
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 0.15rem;
}

.move-list {
  font-family: var(--font-ui);
  font-size: 0.82rem;
  line-height: 1.55;
  color: var(--muted);
  max-height: 220px;
  overflow-y: auto;
}

.move-list .mv {
  display: inline-block;
  min-width: 3.2rem;
  color: var(--ink);
}

.thinking {
  position: absolute;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 0.5rem 1rem;
  border-radius: 999px;
  font-size: 0.8rem;
  color: var(--accent);
  backdrop-filter: blur(10px);
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.7;
  }
  50% {
    opacity: 1;
  }
}

.bottom-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  gap: 0.45rem;
  padding: 0 12px max(14px, env(safe-area-inset-bottom));
  flex-wrap: wrap;
}

/* —— Overlays —— */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(8, 6, 5, 0.55);
  backdrop-filter: blur(6px);
  animation: fade 0.35s ease both;
}

@keyframes fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.overlay-card {
  width: min(380px, 100%);
  background: var(--panel-solid);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 1.75rem 1.5rem;
  text-align: center;
  box-shadow: var(--shadow);
}

.overlay-card h2 {
  font-family: var(--font-display);
  font-size: 2.2rem;
  font-weight: 700;
  margin-bottom: 0.4rem;
}

.overlay-card p {
  color: var(--muted);
  margin-bottom: 1.4rem;
}

.overlay-card .actions {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

/* Promotion */
.promo-choices {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.promo-choices button {
  aspect-ratio: 1;
  font-size: 1.8rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
  color: var(--ink);
}

.promo-choices button:hover {
  border-color: var(--accent);
  background: rgba(196, 165, 116, 0.15);
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.65rem 0;
  border-bottom: 1px solid rgba(196, 165, 116, 0.15);
  text-align: left;
  font-size: 0.9rem;
}

.settings-row:last-child {
  border-bottom: none;
}

.toggle {
  width: 44px;
  height: 26px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.08);
  position: relative;
  cursor: pointer;
}

.toggle.on {
  background: rgba(196, 165, 116, 0.45);
  border-color: var(--accent);
}

.toggle::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--ink);
  transition: transform 0.2s;
}

.toggle.on::after {
  transform: translateX(18px);
}

@media (max-width: 720px) {
  .side-panel {
    top: auto;
    bottom: max(12px, env(safe-area-inset-bottom));
    right: 10px;
    left: 10px;
    width: auto;
    max-height: 42vh;
  }

  .side-panel.collapsed {
    transform: translateY(110%);
    opacity: 0;
    pointer-events: none;
  }

  .top-actions {
    max-width: 48vw;
  }

  .status-pill .value {
    font-size: 1.15rem;
  }

  .bottom-bar .btn-sm span.label {
    display: none;
  }
}

@media (orientation: landscape) and (max-height: 500px) {
  .menu {
    align-items: center;
    padding: 12px;
    overflow-y: auto;
  }

  .brand {
    font-size: 2.2rem;
  }

  .side-panel {
    max-height: 70vh;
    bottom: 12px;
    top: 70px;
  }
}
