﻿:root {
  --bg-1: #081124;
  --bg-2: #10264a;
  --bg-3: #1e4587;
  --panel: #0a1730bf;
  --line: #9ec7ff3f;
  --text: #f0f6ff;
  --muted: #c6d7f5;
  --primary: #ff8c2a;
  --primary-2: #ff5722;
  --good: #4ade80;
  --warn: #facc15;
}

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

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(900px 600px at 10% -10%, #2856a3a3 0, transparent 62%),
    radial-gradient(1000px 700px at 100% 0%, #14305bbf 0, transparent 65%),
    linear-gradient(145deg, var(--bg-1), var(--bg-2) 48%, #0c2140);
  overflow-x: hidden;
  overflow-y: auto;
}

main {
  width: 100%;
  min-height: 100svh;
  height: auto;
}

.screen {
  width: 100%;
  min-height: 100svh;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) 14px calc(env(safe-area-inset-bottom, 0px) + 12px);
  position: relative;
}

.screen[hidden] {
  display: none !important;
}

.panel {
  background: linear-gradient(165deg, #0e2141d6, #081527d9);
  border: 1px solid var(--line);
  border-radius: 18px;
  backdrop-filter: blur(8px);
  box-shadow: 0 16px 45px #00000055;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  border-radius: 12px;
  color: #f7f9ff;
  padding: 11px 12px;
  font-weight: 700;
  background: #2d4f83;
  cursor: pointer;
  transition: 0.15s transform ease, 0.15s filter ease, 0.2s background ease;
}

button:hover {
  filter: brightness(1.09);
}

button:active {
  transform: translateY(1px) scale(0.985);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

button.primary {
  background: linear-gradient(160deg, var(--primary), var(--primary-2));
  box-shadow: 0 8px 24px #ff713b5e;
}

button.ghost {
  background: #ffffff1a;
  border: 1px solid #ffffff33;
}

button.wide {
  width: 100%;
}

label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

input,
select {
  width: 100%;
  border: 1px solid #88b6ff4c;
  border-radius: 10px;
  padding: 10px;
  color: #f4f8ff;
  background: #061127d1;
}

select option {
  background: #0d203f;
}

.boot-screen {
  display: grid;
  place-items: center;
  overflow: hidden;
}

.boot-screen::before,
.boot-screen::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  filter: blur(2px);
  animation: drift 6s ease-in-out infinite;
}

.boot-screen::before {
  width: 420px;
  height: 420px;
  background: radial-gradient(circle, #4ea3ff60, #00000000 70%);
  right: -120px;
  top: -80px;
}

.boot-screen::after {
  width: 460px;
  height: 460px;
  background: radial-gradient(circle, #ff8c2a40, #00000000 74%);
  left: -140px;
  bottom: -150px;
  animation-delay: 0.6s;
}

.boot-core {
  position: relative;
  text-align: center;
  animation: floatin 1.4s ease;
}

.boot-logo {
  width: 110px;
  height: 110px;
  border-radius: 26px;
  margin: 0 auto 12px;
  display: grid;
  place-items: center;
  font-size: 36px;
  font-weight: 900;
  color: #fff;
  background: linear-gradient(165deg, #ff8d2f, #ff5138 45%, #2d8bff);
  box-shadow: 0 0 0 3px #ffffff44 inset, 0 22px 35px #0000006b;
  animation: pulse 1.6s infinite;
}

.boot-logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 24px;
  display: block;
}

.boot-core h1 {
  margin: 0;
  font-size: clamp(30px, 6.2vw, 56px);
}

.boot-core p {
  margin: 6px 0 0;
  color: #d3e3ff;
}

.menu-screen {
  display: grid;
  place-items: center;
  gap: 16px;
  animation: floatin 0.45s ease;
  overflow-y: auto;
  padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 22px);
}

.menu-home {
  width: min(520px, 100%);
  padding: 18px;
  text-align: center;
  display: grid;
  gap: 12px;
}

.menu-home-logo {
  width: 108px;
  height: 108px;
  border-radius: 24px;
  margin: 0 auto;
  box-shadow: 0 0 0 2px #ffffff44 inset, 0 20px 30px #00000066;
  overflow: hidden;
}

.menu-home-logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.menu-home h1 {
  margin: 0;
  font-size: clamp(34px, 6vw, 56px);
}

.tagline {
  margin: 0;
  color: #e1edff;
  font-size: 15px;
}

.version-chip {
  display: inline-block;
  font-size: 12px;
  color: #ffe8b9;
  background: #ff8c2a2e;
  border: 1px solid #ffcf8b55;
  border-radius: 999px;
  padding: 4px 9px;
  margin: 0 auto;
}

.account-label {
  margin: 0;
  color: #bdd6ff;
  font-size: 13px;
}

.menu-main-actions {
  margin-top: 4px;
  display: grid;
  gap: 10px;
}

.menu-main-actions button {
  min-height: 54px;
  font-size: 19px;
}

.menu-main-actions button.primary {
  animation: pulse 1.8s infinite;
}

.menu-secondary-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  max-height: min(65vh, 540px);
  overflow: auto;
  padding-inline-end: 4px;
}

.stats-grid {
  display: grid;
  gap: 8px;
  margin-bottom: 10px;
}

.stats-grid > div {
  background: #0b1e3eb5;
  border: 1px solid #8fb9fa34;
  border-radius: 12px;
  padding: 9px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.stats-grid span {
  color: #bdd4fa;
  font-size: 13px;
}

.stats-grid strong {
  font-size: 18px;
}

.game-screen {
  display: flex;
  flex-direction: column;
  gap: 9px;
  animation: floatin 0.35s ease;
  min-height: 100svh;
  overflow-y: auto;
}

.game-header {
  padding: 10px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.game-header h2 {
  margin: 0;
  font-size: 22px;
}

.game-header p {
  margin: 3px 0 0;
  color: #d7e7ff;
  font-size: 13px;
}

.game-header-actions {
  display: flex;
  gap: 7px;
}

.hud {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.hud > div {
  background: #0b1d3bbd;
  border: 1px solid #8fb9fa38;
  border-radius: 12px;
  padding: 9px;
  text-align: center;
  font-weight: 700;
  font-size: 14px;
}

.canvas-wrap {
  padding: 0;
  overflow: hidden;
  min-height: 340px;
  height: clamp(360px, 62vh, 820px);
  flex: 0 0 auto;
}

.canvas-wrap.compact-board {
  min-height: 260px;
  height: clamp(260px, 46vh, 560px);
}

#gameCanvas {
  width: 100%;
  height: 100%;
  display: block;
}

.controls {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.message {
  margin: 0;
  border-radius: 12px;
  border: 1px solid #8fb9fa3d;
  padding: 10px;
  text-align: center;
  background: #091c38ca;
  min-height: 46px;
}

.overlay {
  position: fixed;
  inset: 0;
  background: #020817c7;
  backdrop-filter: blur(6px);
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 16px;
}

.overlay[hidden] {
  display: none !important;
}

.overlay-card {
  width: min(760px, 100%);
  max-height: 88vh;
  overflow: auto;
  padding: 14px;
}

.overlay-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.overlay-head h3 {
  margin: 0;
  font-size: 22px;
}

.overlay-body {
  margin-top: 10px;
  color: #deebff;
}

.overlay-body p {
  margin: 0 0 10px;
  color: #c8dcff;
}

.auth-box {
  display: grid;
  gap: 10px;
}

.auth-error {
  min-height: 20px;
  color: #ffb5b5;
  font-size: 13px;
  margin: 0;
}

.overlay-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}

.overlay-list li {
  border: 1px solid #92bcff30;
  background: #0b1d3bb5;
  border-radius: 10px;
  padding: 9px;
}

.overlay-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
}

.choice-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.choice-card {
  text-align: start;
  min-height: 120px;
  border-radius: 14px;
  border: 1px solid #89b5ff66;
  background: linear-gradient(160deg, #102a54, #0b1b36);
  padding: 12px;
}

.choice-card strong {
  display: block;
  font-size: 22px;
  margin-bottom: 4px;
}

.choice-card span {
  display: block;
  color: #c3d8ff;
  font-size: 13px;
}

.status-grid {
  display: grid;
  gap: 8px;
}

.status-grid div {
  border: 1px solid #8cb7f544;
  border-radius: 12px;
  background: #0b1d3bb5;
  padding: 10px;
  display: flex;
  justify-content: space-between;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid #ffb86d4a;
  border-radius: 999px;
  padding: 4px 9px;
  color: #ffd7a3;
  background: #ff8c2a1e;
  font-size: 12px;
}

.achieve-grid {
  display: grid;
  gap: 8px;
}

.achieve-item {
  border-radius: 10px;
  padding: 9px;
  border: 1px solid #8eb7f633;
  background: #081a35d8;
  display: grid;
  gap: 7px;
}

.achieve-item.done {
  border-color: #73eb9b66;
  background: #063020ad;
}

.achieve-item span {
  color: #c7dcff;
  font-size: 13px;
}

@keyframes pulse {
  0%,
  100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

@keyframes floatin {
  from { opacity: 0; transform: translateY(14px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes drift {
  0%,
  100% { transform: translateY(0) translateX(0); }
  50% { transform: translateY(-15px) translateX(-10px); }
}

@media (max-width: 980px) {
  .choice-grid {
    grid-template-columns: 1fr;
  }

  .controls {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .screen {
    padding:
      calc(env(safe-area-inset-top, 0px) + 8px)
      10px
      calc(env(safe-area-inset-bottom, 0px) + 10px);
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .game-screen {
    gap: 8px;
  }

  .game-header {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    align-items: stretch;
    padding: 10px;
  }

  .game-header h2 {
    font-size: clamp(34px, 8.5vw, 40px);
    line-height: 1.04;
  }

  .game-header p {
    font-size: 14px;
  }

  .game-header-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    width: 100%;
  }

  .game-header-actions button {
    min-height: 50px;
    font-size: 17px;
  }

  .hud {
    grid-template-columns: 1fr 1fr;
  }

  .hud > div {
    min-height: 52px;
    display: grid;
    place-items: center;
    font-size: 18px;
    padding: 8px;
  }

  .menu-secondary-actions {
    grid-template-columns: 1fr 1fr;
  }

  .canvas-wrap {
    min-height: 300px;
    height: clamp(300px, 50vh, 520px);
    border-radius: 14px;
  }

  .canvas-wrap.compact-board {
    min-height: 250px;
    height: clamp(250px, 42vh, 430px);
  }

  .controls {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .controls button {
    min-height: 56px;
    font-size: 18px;
    font-weight: 800;
  }

  #gameCanvas {
    height: 100%;
  }
}
