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

:root {
  color-scheme: dark;
  --ink: #f3f5e9;
  --muted: #949b8f;
  --lime: #d8ff4f;
  --orange: #ff6b3d;
  --surface: #161b17;
  --surface-2: #1c221d;
  --line: #30382f;
  --board: #252c25;
  --board-line: #465044;
  --wall: #b8c3b2;
  --cell: calc(100% / 9);
  font-family: 'DM Sans', system-ui, sans-serif;
  background: #101410;
  color: var(--ink);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    radial-gradient(circle at 65% 0%, rgba(105, 134, 68, .16), transparent 34rem),
    radial-gradient(circle at 10% 45%, rgba(255, 107, 61, .05), transparent 28rem),
    #101410;
  overflow-x: hidden;
}

button, a { font: inherit; }
button { color: inherit; }

.grain {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  opacity: .05;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.7'/%3E%3C/svg%3E");
}

.site-header {
  width: min(1440px, calc(100% - 64px));
  margin: 0 auto;
  height: 88px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(216, 255, 79, .15);
}

.brand {
  color: var(--ink);
  display: inline-flex;
  gap: 13px;
  align-items: center;
  text-decoration: none;
  font: 800 15px/1 'Manrope', sans-serif;
  letter-spacing: .18em;
}

.brand-mark { display: grid; gap: 3px; transform: rotate(-7deg); }
.brand-mark i { display: block; height: 4px; width: 23px; background: var(--lime); }
.brand-mark i:nth-child(2) { margin-left: 7px; }
.brand-mark i:nth-child(3) { width: 15px; }

.text-button {
  border: 0;
  background: transparent;
  padding: 10px 0;
  color: #b9c0b5;
  cursor: pointer;
  border-bottom: 1px solid #5b6459;
  transition: color .2s, border-color .2s;
}
.text-button:hover { color: var(--lime); border-color: var(--lime); }

.hero {
  width: min(1120px, calc(100% - 48px));
  min-height: 480px;
  margin: 0 auto;
  padding: 76px 0 64px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.eyebrow, .panel-label {
  font: 700 10px/1.2 'Manrope', sans-serif;
  letter-spacing: .22em;
  color: var(--lime);
}

.hero h1 {
  max-width: 900px;
  margin: 20px 0 22px;
  font: 800 clamp(52px, 7vw, 102px)/.93 'Manrope', sans-serif;
  letter-spacing: -.065em;
  text-transform: uppercase;
}
.hero h1 em { color: var(--lime); font-style: normal; }
.hero p { max-width: 620px; margin: 0; color: #a5ada1; font-size: 17px; line-height: 1.65; }

.hero-cta {
  margin-top: 34px;
  display: inline-flex;
  gap: 28px;
  align-items: center;
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
}
.hero-cta span { color: var(--lime); font-size: 20px; animation: drift 1.6s ease-in-out infinite; }
@keyframes drift { 50% { transform: translateY(5px); } }

.game-shell {
  width: min(1440px, calc(100% - 48px));
  margin: 0 auto 100px;
  padding: 34px;
  background: rgba(22, 27, 23, .86);
  border: 1px solid #2b322b;
  border-radius: 24px;
  display: grid;
  grid-template-columns: minmax(200px, 270px) minmax(420px, 660px) minmax(200px, 270px);
  justify-content: center;
  gap: 34px;
  box-shadow: 0 35px 100px rgba(0, 0, 0, .28);
  backdrop-filter: blur(14px);
  scroll-margin-top: 20px;
}

.panel { min-width: 0; padding: 12px 0; display: flex; flex-direction: column; gap: 34px; }
.game-info { justify-content: space-between; }

.mode-switch, .difficulty-switch {
  margin-top: 14px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #111511;
}
.mode-button, .difficulty-button {
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #80877e;
  font-size: 12px;
  cursor: pointer;
  transition: .2s;
}
.mode-button.active, .difficulty-button.active { color: var(--ink); background: #293128; box-shadow: inset 0 0 0 1px #3b4638; }
.difficulty-panel { margin-top: 20px; }
.difficulty-panel[hidden] { display: none; }
.difficulty-switch { grid-template-columns: repeat(3, 1fr); margin-top: 10px; }
.difficulty-button { padding: 0 5px; }
.difficulty-button:disabled { cursor: wait; opacity: .55; }

.players { display: grid; gap: 8px; }
.player-card {
  display: grid;
  grid-template-columns: 32px 1fr auto 15px;
  align-items: center;
  gap: 10px;
  padding: 14px 12px;
  border: 1px solid transparent;
  border-radius: 10px;
  color: #777f75;
  transition: .2s;
}
.player-card.active { background: #1e251e; color: var(--ink); border-color: #354031; }
.player-card b { display: block; font: 700 13px/1.2 'Manrope', sans-serif; }
.player-card small { display: block; margin-top: 4px; color: #767e74; font-size: 10px; }
.player-card strong { font: 700 18px/1 'Manrope', sans-serif; }
.pawn-swatch { width: 24px; height: 24px; border-radius: 50%; box-shadow: inset 0 -4px 8px rgba(0, 0, 0, .28); }
.pawn-one { background: var(--lime); }
.pawn-two { background: var(--orange); }
.wall-mini { height: 16px; width: 5px; border-radius: 1px; background: currentColor; transform: rotate(25deg); opacity: .7; }

.status-block { border-left: 2px solid var(--lime); padding-left: 14px; }
.status-block p { margin: 9px 0 0; color: #c2c8bf; font-size: 13px; line-height: 1.55; }
.panel-actions { display: flex; gap: 8px; }
.secondary-button {
  flex: 1;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: transparent;
  color: #a5aca2;
  font-size: 12px;
  cursor: pointer;
  transition: .2s;
}
.secondary-button:hover:not(:disabled) { border-color: #64705f; color: var(--ink); }
.secondary-button:disabled { opacity: .35; cursor: not-allowed; }

.board-column { min-width: 0; }
.goal-label { height: 25px; display: flex; justify-content: center; align-items: center; }
.goal-label span { font: 700 8px/1 'Manrope', sans-serif; letter-spacing: .2em; }
.goal-top { color: var(--lime); }
.goal-bottom { color: var(--orange); }
.board-frame {
  width: 100%;
  aspect-ratio: 1;
  border: 12px solid #333b32;
  border-radius: 4px;
  background: #333b32;
  box-shadow: 0 20px 50px rgba(0, 0, 0, .35), inset 0 0 0 1px #50594e;
  border-top-color: color-mix(in srgb, var(--lime) 72%, #333b32);
  border-bottom-color: color-mix(in srgb, var(--orange) 76%, #333b32);
}
.board {
  position: relative;
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  grid-template-rows: repeat(9, 1fr);
  background-color: var(--board);
  background-image:
    linear-gradient(to right, transparent calc(100% - 1px), var(--board-line) 0),
    linear-gradient(to bottom, transparent calc(100% - 1px), var(--board-line) 0);
  background-size: calc(100% / 9) calc(100% / 9);
  overflow: visible;
}

.cell {
  position: relative;
  z-index: 1;
  border: 0;
  background: transparent;
  padding: 0;
  cursor: default;
}
.cell:focus-visible { outline: 2px solid white; outline-offset: -3px; }
.cell.goal-player-one { background: linear-gradient(to bottom, rgba(216, 255, 79, .18), rgba(216, 255, 79, .035) 58%, transparent); }
.cell.goal-player-two { background: linear-gradient(to top, rgba(255, 107, 61, .2), rgba(255, 107, 61, .04) 58%, transparent); }
.cell.legal-move { cursor: pointer; }
.cell.legal-move::after {
  content: '';
  position: absolute;
  width: 20%;
  aspect-ratio: 1;
  left: 40%;
  top: 40%;
  border-radius: 50%;
  background: var(--lime);
  box-shadow: 0 0 0 7px rgba(216, 255, 79, .08);
  transition: transform .18s, box-shadow .18s;
}
.cell.legal-move:hover::after { transform: scale(1.45); box-shadow: 0 0 0 10px rgba(216, 255, 79, .13); }

.pawn {
  position: absolute;
  z-index: 5;
  width: 45%;
  aspect-ratio: 1;
  left: 27.5%;
  top: 27.5%;
  border-radius: 50%;
  box-shadow: 0 7px 12px rgba(0, 0, 0, .38), inset 0 -5px 7px rgba(0, 0, 0, .2), inset 0 2px 3px rgba(255, 255, 255, .3);
  transition: .25s;
}
.pawn i { position: absolute; inset: 28%; border: 1px solid rgba(20, 26, 18, .3); border-radius: 50%; }
.pawn-1 { background: var(--lime); }
.pawn-2 { background: var(--orange); }

.placed-wall, .wall-preview {
  position: absolute;
  z-index: 7;
  border: 0;
  border-radius: 3px;
  transform-origin: center;
}
.placed-wall { background: linear-gradient(90deg, #a5b19f, #d4ded0 50%, #8d9988); box-shadow: 0 2px 5px rgba(0, 0, 0, .55); }
.placed-wall.horizontal, .wall-preview.horizontal {
  left: calc(var(--col) * var(--cell) - 1px);
  top: calc((var(--row) + 1) * var(--cell) - 5px);
  width: calc(var(--cell) * 2 + 2px);
  height: 10px;
}
.placed-wall.vertical, .wall-preview.vertical {
  top: calc(var(--row) * var(--cell) - 1px);
  left: calc((var(--col) + 1) * var(--cell) - 5px);
  height: calc(var(--cell) * 2 + 2px);
  width: 10px;
  background: linear-gradient(180deg, #a5b19f, #d4ded0 50%, #8d9988);
}
.wall-preview {
  z-index: 10;
  pointer-events: none;
  background: var(--lime);
  opacity: .82;
  box-shadow: 0 0 0 4px rgba(216, 255, 79, .2), 0 0 20px rgba(216, 255, 79, .32);
}
.wall-preview.vertical { background: var(--lime); }
.wall-preview.invalid {
  background: #ff4f4f;
  opacity: .7;
  box-shadow: 0 0 0 4px rgba(255, 79, 79, .18), 0 0 18px rgba(255, 79, 79, .25);
}

.move-panel { justify-content: space-between; }
.wall-instruction { margin: 10px 0 18px; color: #929990; font-size: 12px; line-height: 1.55; }
.wall-rack { display: grid; gap: 10px; }
.draggable-wall {
  min-height: 70px;
  display: grid;
  grid-template-columns: 52px 1fr;
  align-items: center;
  gap: 12px;
  padding: 10px 13px;
  border: 1px solid #465344;
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(216, 255, 79, .075), transparent), #151a15;
  color: #c5ccbf;
  text-align: left;
  cursor: grab;
  touch-action: none;
  user-select: none;
  transition: border-color .18s, background .18s, opacity .18s, transform .18s;
}
.draggable-wall:hover:not(:disabled) { border-color: var(--lime); background-color: #1c231b; transform: translateY(-1px); }
.draggable-wall:active:not(:disabled), .draggable-wall.dragging { cursor: grabbing; opacity: .48; }
.draggable-wall:disabled { opacity: .3; cursor: not-allowed; }
.draggable-wall i {
  display: block;
  width: 48px;
  height: 9px;
  border-radius: 3px;
  background: linear-gradient(90deg, #91a083, #d7e2d2 48%, #84917e);
  box-shadow: 0 3px 7px rgba(0, 0, 0, .42);
}
.draggable-wall.vertical i { transform: rotate(90deg); }
.draggable-wall.player-two-wall:hover:not(:disabled) { border-color: var(--orange); }
.draggable-wall span { font: 600 12px/1.3 'Manrope', sans-serif; }
.drag-ghost {
  position: fixed;
  z-index: 1000;
  width: 106px;
  height: 11px;
  margin: -5px 0 0 -53px;
  border-radius: 3px;
  pointer-events: none;
  background: linear-gradient(90deg, #a5b19f, #eef7eb 50%, #8d9988);
  box-shadow: 0 7px 18px rgba(0, 0, 0, .5), 0 0 0 2px rgba(216, 255, 79, .45);
  opacity: .92;
}
.drag-ghost.vertical { transform: rotate(90deg); }
.drag-ghost.invalid { box-shadow: 0 7px 18px rgba(0, 0, 0, .5), 0 0 0 2px rgba(255, 79, 79, .7); }
.hint-card { display: grid; grid-template-columns: 18px 1fr; gap: 10px; padding: 14px; background: #121612; border-radius: 8px; color: var(--lime); }
.hint-card p { margin: 0; color: #858d82; font-size: 11px; line-height: 1.55; }

dialog {
  color: var(--ink);
  background: #171c17;
  border: 1px solid #3a4437;
  border-radius: 16px;
  box-shadow: 0 30px 100px rgba(0, 0, 0, .65);
}
dialog::backdrop { background: rgba(5, 8, 5, .78); backdrop-filter: blur(6px); }
.rules-dialog { width: min(610px, calc(100% - 32px)); padding: 28px; }
.dialog-head { display: flex; justify-content: space-between; align-items: flex-start; }
.dialog-head h2, .win-dialog h2 { margin: 8px 0 0; font: 800 34px/1 'Manrope', sans-serif; letter-spacing: -.04em; }
.dialog-close { width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line); background: transparent; font-size: 25px; cursor: pointer; }
.rules-list { list-style: none; padding: 0; margin: 27px 0; display: grid; gap: 5px; }
.rules-list li { display: grid; grid-template-columns: 35px 1fr; gap: 13px; padding: 14px 0; border-top: 1px solid #2d352d; }
.rules-list li > span { color: var(--lime); font: 700 11px 'Manrope', sans-serif; }
.rules-list b { font: 700 14px 'Manrope', sans-serif; }
.rules-list p { margin: 5px 0 0; color: #929990; font-size: 12px; line-height: 1.55; }
.primary-button { width: 100%; min-height: 48px; border: 0; border-radius: 8px; background: var(--lime); color: #141813; font-weight: 800; cursor: pointer; }
.primary-button:hover { background: #e5ff7e; }

.win-dialog { width: min(430px, calc(100% - 32px)); padding: 38px; text-align: center; }
.win-dialog p { color: #929990; margin: 13px 0 26px; }
.win-symbol { width: 66px; height: 66px; margin: 0 auto 25px; display: grid; place-items: center; border-radius: 50%; background: var(--lime); color: #151a14; font-size: 28px; }

@media (max-width: 1120px) {
  .game-shell { grid-template-columns: 220px minmax(400px, 620px); }
  .move-panel { grid-column: 1 / -1; display: grid; grid-template-columns: 2fr 1fr; align-items: end; gap: 20px; }
  .wall-rack { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 780px) {
  .site-header { width: calc(100% - 32px); height: 70px; }
  .hero { min-height: 410px; padding-top: 60px; }
  .hero h1 { font-size: clamp(42px, 13vw, 72px); }
  .hero p { font-size: 15px; }
  .game-shell { width: calc(100% - 20px); padding: 18px; grid-template-columns: 1fr; gap: 22px; border-radius: 15px; }
  .game-info { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
  .players, .status-block, .panel-actions { grid-column: 1 / -1; }
  .players { grid-template-columns: 1fr 1fr; }
  .board-column { grid-row: 2; }
  .move-panel { grid-column: auto; grid-row: 3; display: grid; grid-template-columns: 1fr; gap: 20px; }
  .hint-card { display: none; }
  .board-frame { border-width: 8px; }
}

@media (max-width: 500px) {
  .site-header { width: calc(100% - 24px); }
  .brand { font-size: 13px; }
  .hero { width: calc(100% - 28px); padding-top: 48px; }
  .hero h1 { font-size: 43px; }
  .hero p { font-size: 14px; }
  .game-shell { padding: 13px; }
  .game-info { grid-template-columns: 1fr; }
  .players { grid-template-columns: 1fr; }
  .game-info > div { grid-column: 1; }
  .pawn { width: 54%; left: 23%; top: 23%; }
  .placed-wall.horizontal, .wall-preview.horizontal { height: 8px; top: calc((var(--row) + 1) * var(--cell) - 4px); }
  .placed-wall.vertical, .wall-preview.vertical { width: 8px; left: calc((var(--col) + 1) * var(--cell) - 4px); }
  .wall-rack { grid-template-columns: 1fr 1fr; }
  .draggable-wall { min-height: 58px; grid-template-columns: 36px 1fr; padding: 8px; gap: 8px; }
  .draggable-wall i { width: 34px; height: 7px; }
  .draggable-wall span { font-size: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
