@import url("https://fonts.googleapis.com/css2?family=Barlow+Condensed:wght@600;700;800&family=Manrope:wght@400;500;600;700&display=swap");

:root {
  --honolulu: #0076b6;
  --honolulu-deep: #005a8c;
  --honolulu-soft: rgba(0, 118, 182, 0.12);
  --silver: #b0b7bc;
  --silver-soft: #e6eaed;
  --white: #ffffff;
  --navy: #0b1c2c;
  --ink: #122334;
  --muted: #5d6b76;
  --panel: rgba(255, 255, 255, 0.92);
  --line: #cfd6db;
  --danger: #9b2c2c;
  --board-light: #e8eef3;
  --board-dark: #3f7ea8;
  --board-border: #1f3f57;
  --shadow: 0 18px 48px rgba(11, 28, 44, 0.14);
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

html {
  overflow-x: hidden;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--ink);
  text-align: left;
  font-family: Manrope, sans-serif;
  background:
    radial-gradient(circle at top right, rgba(0, 118, 182, 0.18), transparent 34%),
    radial-gradient(circle at bottom left, rgba(176, 183, 188, 0.35), transparent 28%),
    linear-gradient(165deg, #f7f9fb 0%, #e9eef2 52%, #f4f7fa 100%);
  overflow-x: hidden;
  overflow-anchor: none;
  -webkit-tap-highlight-color: transparent;
}

.page {
  width: min(1120px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 2rem 0 calc(3rem + env(safe-area-inset-bottom, 0px));
  overflow-anchor: none;
}

.hero {
  text-align: left;
  margin-bottom: 1.75rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 0.4rem;
  color: var(--honolulu);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.hero h1 {
  margin: 0;
  font-family: "Barlow Condensed", sans-serif;
  font-size: clamp(3rem, 8vw, 4.8rem);
  font-weight: 800;
  letter-spacing: 0.02em;
  line-height: 0.95;
  color: var(--navy);
}

.tagline {
  margin: 0.75rem 0 0;
  max-width: 36rem;
  color: var(--muted);
  font-size: 1.05rem;
}

.about-button {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  width: auto;
  margin-top: 0.95rem;
  padding: 0.55rem 0.9rem;
  border: 1px solid var(--silver);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--honolulu-deep);
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: none;
}

.about-button:hover {
  background: var(--white);
  border-color: var(--honolulu);
  color: var(--honolulu);
}

.about-icon {
  font-size: 1rem;
  line-height: 1;
  color: var(--honolulu);
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(260px, 0.7fr);
  gap: 1.25rem;
  align-items: start;
}

.board-panel,
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.board-panel {
  padding: 1rem;
  overflow-anchor: none;
}

#board {
  width: min(100%, 560px) !important;
  height: auto !important;
  max-width: min(100%, 560px) !important;
  max-height: none !important;
  margin: 0 auto !important;
  margin-bottom: 0 !important;
  padding: 0 !important;
  border: none !important;
  box-shadow: none !important;
  line-height: 0;
  font-size: 0;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  overflow-anchor: none;
}

#board .chessboard-63f37 {
  line-height: 0;
}

#board .board-b72b1 {
  display: block;
  margin: 0 auto;
  border: 3px solid var(--board-border) !important;
  border-radius: 6px;
  overflow: hidden;
}

#board .piece-417db,
#board img,
body > .piece-417db {
  -webkit-user-drag: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  pointer-events: none;
}

#board .square-55d63 {
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

#board .square-55d63.is-selected {
  box-shadow:
    inset 0 0 0 3px #46c7ed,
    inset 0 0 0 5px rgba(255, 255, 255, 0.55);
}

.white-1e1d7 {
  background-color: var(--board-light) !important;
  color: var(--honolulu-deep) !important;
}

.black-3c85d {
  background-color: var(--board-dark) !important;
  color: var(--silver-soft) !important;
}

.highlight1-32417 {
  box-shadow:
    inset 0 0 0 3px #46c7ed,
    inset 0 0 0 5px rgba(255, 255, 255, 0.5) !important;
}

.highlight2-9c5d2 {
  box-shadow: inset 0 0 0 3px #a7e8f5 !important;
}

.status {
  margin-top: 0.7rem;
  color: var(--ink);
  font-size: 0.98rem;
  font-weight: 600;
  overflow-anchor: none;
}

.board-feedback {
  display: grid;
  gap: 0.25rem;
  min-height: 1.35rem;
  margin-top: 0.35rem;
  overflow-anchor: none;
}

.thinking,
.error {
  min-height: 1.35rem;
  font-size: 0.98rem;
  line-height: 1.35rem;
  opacity: 0;
  transform: translateY(2px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  pointer-events: none;
}

.thinking {
  color: var(--honolulu);
  font-weight: 600;
}

.error {
  color: var(--danger);
}

.thinking.is-active,
.error.is-active {
  opacity: 1;
  transform: none;
}

.side-panel {
  display: grid;
  gap: 1rem;
}

.card {
  padding: 1.1rem 1.15rem 1.2rem;
  text-align: left;
}

.card h2 {
  margin: 0 0 0.9rem;
  font-family: "Barlow Condensed", sans-serif;
  font-size: 1.15rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--honolulu-deep);
}

.field {
  display: grid;
  gap: 0.35rem;
  margin-bottom: 0.85rem;
  font-size: 0.95rem;
}

.field span {
  color: var(--muted);
}

.depth-field {
  gap: 0.55rem;
}

.depth-heading {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  color: var(--muted);
  font-size: 0.95rem;
}

.depth-heading strong {
  color: var(--honolulu);
  font-family: "Barlow Condensed", sans-serif;
  font-size: 1.55rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  line-height: 1;
}

.depth-recommended {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.01em;
}

.depth-recommended[hidden] {
  display: none !important;
}

#depthSlider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 0.55rem;
  margin: 0.15rem 0 0;
  border: none;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--silver-soft), var(--honolulu));
  outline: none;
  cursor: pointer;
}

#depthSlider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 1.35rem;
  height: 1.35rem;
  border-radius: 50%;
  border: 3px solid var(--white);
  background: var(--honolulu);
  box-shadow: 0 2px 10px rgba(0, 118, 182, 0.35);
  cursor: pointer;
}

#depthSlider::-moz-range-thumb {
  width: 1.35rem;
  height: 1.35rem;
  border-radius: 50%;
  border: 3px solid var(--white);
  background: var(--honolulu);
  box-shadow: 0 2px 10px rgba(0, 118, 182, 0.35);
  cursor: pointer;
}

#depthSlider:focus-visible {
  outline: 2px solid var(--honolulu);
  outline-offset: 4px;
}

#depthSlider:disabled {
  opacity: 0.55;
  cursor: wait;
}

.depth-scale {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.depth-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
}

select,
button {
  font: inherit;
}

select,
button {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--line);
  padding: 0.75rem 0.9rem;
  background: var(--white);
  color: var(--ink);
}

select:focus,
button:focus-visible {
  outline: 2px solid var(--honolulu);
  outline-offset: 2px;
}

button {
  border: none;
  background: var(--honolulu);
  color: var(--white);
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease;
}

button:hover {
  background: var(--honolulu-deep);
}

button:disabled {
  opacity: 0.6;
  cursor: wait;
}

.button-secondary {
  background: var(--white);
  color: var(--honolulu-deep);
  border: 1px solid var(--silver);
}

.button-secondary:hover {
  background: var(--silver-soft);
}

.moves-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 320px;
  overflow: auto;
  overscroll-behavior: contain;
  overflow-anchor: none;
  -webkit-overflow-scrolling: touch;
}

.move-row {
  display: grid;
  grid-template-columns: 2.2rem 1fr 1fr;
  gap: 0.4rem;
  padding: 0.35rem 0.2rem;
  border-bottom: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}

.move-row:nth-child(even) {
  background: var(--honolulu-soft);
}

.move-index {
  color: var(--muted);
}

.game-over,
.megatron-wins {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: max(1rem, env(safe-area-inset-top, 0px))
    max(1rem, env(safe-area-inset-right, 0px))
    max(1rem, env(safe-area-inset-bottom, 0px))
    max(1rem, env(safe-area-inset-left, 0px));
}

.game-over {
  background: rgba(11, 28, 44, 0.55);
  z-index: 40;
}

.megatron-wins {
  background: rgba(0, 0, 0, 0.88);
  z-index: 60;
}

.game-over[hidden],
.megatron-wins[hidden],
.promotion-menu[hidden],
.highlight-video[hidden],
.about-modal[hidden] {
  display: none !important;
}

.about-modal {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  padding: max(1rem, env(safe-area-inset-top, 0px))
    max(1rem, env(safe-area-inset-right, 0px))
    max(1rem, env(safe-area-inset-bottom, 0px))
    max(1rem, env(safe-area-inset-left, 0px));
}

.about-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(11, 28, 44, 0.55);
}

.about-modal-card {
  position: relative;
  z-index: 1;
  width: min(560px, 100%);
  max-height: min(84vh, 720px);
  overflow: auto;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
}

.about-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.15rem 1.25rem 0.85rem;
  border-bottom: 1px solid var(--line);
}

.about-modal-header h2 {
  margin: 0;
  font-family: "Barlow Condensed", sans-serif;
  font-size: 1.85rem;
  letter-spacing: 0.03em;
  color: var(--navy);
}

.about-close {
  width: 2.25rem;
  min-width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border-radius: 999px;
  border: 1px solid var(--silver);
  background: var(--white);
  color: var(--honolulu-deep);
  font-size: 1.4rem;
  font-weight: 500;
  line-height: 1;
}

.about-close:hover {
  background: var(--silver-soft);
}

.about-modal-body {
  padding: 1rem 1.25rem 1.35rem;
  color: var(--ink);
}

.about-modal-body p {
  margin: 0 0 0.9rem;
  color: var(--muted);
  font-size: 0.98rem;
  line-height: 1.55;
}

.about-meta {
  margin: 1.15rem 0 1rem;
  padding-top: 0.95rem;
  border-top: 1px solid var(--line);
}

.about-meta-row {
  display: grid;
  gap: 0.2rem;
  margin: 0 0 0.85rem;
}

.about-meta-row:last-child {
  margin-bottom: 0;
}

.about-meta dt {
  margin: 0;
  color: var(--honolulu-deep);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.about-meta dd {
  margin: 0;
  color: var(--ink);
  font-size: 0.95rem;
  line-height: 1.45;
}

.about-github {
  display: inline-flex;
  align-items: center;
  margin-top: 0.35rem;
  padding: 0.7rem 1rem;
  border-radius: 12px;
  background: var(--honolulu);
  color: var(--white);
  font-size: 0.95rem;
  font-weight: 700;
  text-decoration: none;
}

.about-github:hover {
  background: var(--honolulu-deep);
}

body.about-open {
  overflow: hidden;
}

.game-over-card,
.megatron-wins-panel {
  width: min(520px, 100%);
  text-align: center;
}

.game-over-card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.game-over-card h2 {
  margin: 0 0 0.5rem;
  font-family: "Barlow Condensed", sans-serif;
  font-size: 2rem;
  letter-spacing: 0.04em;
  color: var(--navy);
}

.game-over-card p {
  margin: 0 0 1rem;
  color: var(--muted);
}

.megatron-wins-panel {
  display: grid;
  gap: 1rem;
  justify-items: center;
}

.megatron-wins-text {
  margin: 0;
  max-width: 96vw;
  font-family: "Barlow Condensed", sans-serif;
  font-size: clamp(2.8rem, 12vw, 6.5rem);
  font-weight: 800;
  letter-spacing: 0.08em;
  line-height: 0.95;
  color: #ff3c00;
  text-shadow: 0 0 24px rgba(255, 60, 0, 0.45);
  animation: megatron-blink 1s infinite;
}

@keyframes megatron-blink {
  0% {
    opacity: 1;
  }
  50% {
    opacity: 0.2;
  }
  100% {
    opacity: 1;
  }
}

.highlight-video {
  display: block;
  width: min(100%, 420px);
  max-height: 42vh;
  margin: 0 auto;
  border-radius: 14px;
  border: 3px solid var(--white);
  background: #111;
  object-fit: contain;
}

.megatron-wins-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  width: min(100%, 420px);
}

.promotion-menu {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  gap: 0.75rem;
  padding: 1rem;
  border-radius: 16px;
  background: var(--navy);
  border: 1px solid var(--silver);
  box-shadow: var(--shadow);
  z-index: 50;
}

.promo-icon {
  width: 56px;
  height: 56px;
  cursor: pointer;
  background: var(--white);
  border-radius: 10px;
  padding: 0.25rem;
  -webkit-user-drag: none;
  -webkit-touch-callout: none;
  user-select: none;
}

@media (max-width: 900px) {
  .page {
    width: min(1120px, calc(100% - 1.25rem));
    padding-top: 1.25rem;
  }

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

  .hero {
    text-align: center;
    margin-bottom: 1.25rem;
  }

  .tagline {
    margin-left: auto;
    margin-right: auto;
  }

  .about-button {
    display: inline-flex;
    margin-left: auto;
    margin-right: auto;
  }

  .hero {
    display: flex;
    flex-direction: column;
    align-items: center;
  }

  #board {
    width: min(100%, calc(100vw - 2.5rem)) !important;
    max-width: min(100%, calc(100vw - 2.5rem)) !important;
  }

  .moves-list {
    max-height: 220px;
  }

  .megatron-wins-actions {
    grid-template-columns: 1fr;
  }

  #depthSlider::-webkit-slider-thumb {
    width: 1.55rem;
    height: 1.55rem;
  }

  #depthSlider::-moz-range-thumb {
    width: 1.55rem;
    height: 1.55rem;
  }
}

@media (max-width: 480px) {
  .hero h1 {
    font-size: clamp(2.4rem, 14vw, 3.4rem);
  }

  .megatron-wins-text {
    font-size: clamp(2.2rem, 14vw, 4rem);
  }

  .highlight-video {
    max-height: 36vh;
  }

  .about-modal-header {
    padding: 1rem 1rem 0.75rem;
  }

  .about-modal-body {
    padding: 0.9rem 1rem 1.15rem;
  }

  .about-modal-body p {
    margin-bottom: 0.75rem;
    font-size: 0.94rem;
  }

  .about-github {
    width: 100%;
    justify-content: center;
  }
}

@media (orientation: landscape) and (max-height: 520px) {
  .page {
    padding-top: 0.75rem;
    padding-bottom: 1rem;
  }

  .hero {
    margin-bottom: 0.75rem;
    padding-bottom: 0.6rem;
  }

  .hero h1 {
    font-size: 2.4rem;
  }

  .tagline {
    display: none;
  }

  .moves-list {
    max-height: 140px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .thinking,
  .error,
  button {
    transition: none;
  }

  .megatron-wins-text {
    animation: none;
    opacity: 1;
  }
}
