:root {
  --navy-950: #031127;
  --navy-900: #071b3c;
  --navy-800: #0a2b54;
  --blue: #0c70b8;
  --cyan: #45d9dc;
  --green: #46e59a;
  --green-dark: #0c8a68;
  --gold: #f2c451;
  --silver: #d8e7f4;
  --ink: #eaf7ff;
  --muted: #8eb7ca;
  --panel: rgba(5, 31, 60, .78);
  --line: rgba(102, 225, 211, .18);
  --cell: clamp(38px, 7.1vw, 75px);
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--navy-950); }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 72% 12%, rgba(14, 144, 132, .22), transparent 27%),
    radial-gradient(circle at 12% 78%, rgba(8, 102, 160, .28), transparent 30%),
    linear-gradient(145deg, #020b1c 0%, #082447 48%, #052b38 100%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow-x: hidden;
}

button { font: inherit; }
button:focus-visible, summary:focus-visible { outline: 3px solid var(--green); outline-offset: 3px; }

.sky { position: fixed; inset: 0; pointer-events: none; overflow: hidden; opacity: .8; }
.sky::before {
  content: ""; position: absolute; inset: 0;
  background-image: linear-gradient(rgba(91, 208, 204, .025) 1px, transparent 1px), linear-gradient(90deg, rgba(91, 208, 204, .025) 1px, transparent 1px);
  background-size: 42px 42px;
  transform: perspective(550px) rotateX(58deg) scale(1.5) translateY(28%);
}
.star { position: absolute; width: 3px; height: 3px; border-radius: 50%; background: #fff; box-shadow: 0 0 13px 3px var(--cyan); animation: drift 7s ease-in-out infinite; }
.star-a { top: 12%; left: 8%; }.star-b { top: 19%; right: 11%; animation-delay: -3s; }.star-c { bottom: 16%; left: 58%; animation-delay: -5s; }
@keyframes drift { 50% { transform: translateY(-12px); opacity: .35; } }

.app-shell { position: relative; width: min(1180px, calc(100% - 28px)); margin: 0 auto; padding: 22px 0 18px; }
.masthead { display: flex; align-items: center; gap: 17px; margin-bottom: 17px; }
.brand-mark {
  width: 64px; aspect-ratio: 1; flex: 0 0 auto; display: grid; place-items: center; transform: rotate(45deg);
  border: 1px solid rgba(83, 233, 188, .72); background: linear-gradient(145deg, rgba(15, 100, 114, .7), rgba(4, 26, 59, .92));
  box-shadow: 0 0 30px rgba(53, 214, 181, .14), inset 0 0 18px rgba(67, 230, 194, .15);
}
.brand-mark::before { content: ""; position: absolute; width: 72%; height: 72%; border: 1px solid rgba(242, 196, 81, .5); }
.brand-mark span { transform: rotate(-45deg); color: var(--gold); font-family: Georgia, serif; font-weight: 900; font-size: 22px; letter-spacing: -2px; text-shadow: 0 0 12px rgba(242, 196, 81, .5); }
.brand-copy { min-width: 0; }
.eyebrow { margin: 0 0 4px; color: var(--green); font-size: 10px; font-weight: 800; letter-spacing: .24em; text-transform: uppercase; }
h1 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: clamp(29px, 4vw, 46px); line-height: .95; letter-spacing: .025em; text-transform: uppercase; }
h1 em { color: var(--gold); font-style: normal; }
.subtitle { margin: 7px 0 0; color: var(--muted); font-size: 13px; }
.icon-button { margin-left: auto; width: 44px; aspect-ratio: 1; border: 1px solid var(--line); border-radius: 50%; background: rgba(2, 23, 48, .65); color: var(--green); cursor: pointer; }
.icon-button:hover { border-color: var(--green); background: rgba(14, 104, 94, .3); }
.sound-off { display: none; }
.icon-button[aria-pressed="false"] .sound-on { display: none; }
.icon-button[aria-pressed="false"] .sound-off { display: inline; }

.game-layout { display: grid; grid-template-columns: minmax(0, 1fr) 345px; gap: 17px; align-items: stretch; }
.panel { border: 1px solid var(--line); background: linear-gradient(145deg, rgba(5, 29, 60, .88), rgba(5, 50, 64, .7)); box-shadow: 0 22px 55px rgba(0, 5, 20, .34), inset 0 1px rgba(255,255,255,.025); backdrop-filter: blur(15px); }
.battlefield { min-width: 0; padding: 16px clamp(10px, 2.2vw, 24px) 22px; border-radius: 6px 28px 6px 28px; display: flex; flex-direction: column; justify-content: center; }
.status-row { display: flex; align-items: center; min-height: 61px; padding: 0 8px 12px; gap: 12px; border-bottom: 1px solid var(--line); }
.turn-token { width: 45px; aspect-ratio: 1; flex: 0 0 auto; border-radius: 50%; background: url("assets/jeton-or.png") center/cover; filter: drop-shadow(0 0 9px rgba(242, 196, 81, .4)); transition: .25s ease; }
.turn-token.ai { background-image: url("assets/jeton-argent.png"); filter: drop-shadow(0 0 9px rgba(128, 218, 255, .4)); }
.status-copy { display: flex; flex-direction: column; min-width: 0; }
.status-copy span { color: var(--green); font-size: 9px; line-height: 1.5; font-weight: 900; letter-spacing: .2em; text-transform: uppercase; }
.status-copy strong { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.round-badge { margin-left: auto; color: var(--muted); font-size: 9px; letter-spacing: .13em; white-space: nowrap; }
.round-badge span { color: var(--gold); font-size: 19px; font-family: Georgia, serif; margin-left: 5px; }

.board-wrap { position: relative; width: max-content; max-width: 100%; margin: 12px auto 2px; }
.column-controls { display: grid; grid-template-columns: repeat(7, var(--cell)); gap: clamp(3px, .7vw, 7px); margin: 0 13px 7px; }
.column-control { height: 27px; border: 0; border-radius: 4px; background: rgba(69, 217, 220, .045); color: rgba(142, 183, 202, .72); font-size: 10px; cursor: pointer; transition: .15s ease; }
.column-control:hover, .column-control.selected { color: var(--green); background: rgba(70, 229, 154, .13); transform: translateY(-2px); }
.column-control.full { opacity: .25; cursor: not-allowed; }
.board {
  --gap: clamp(3px, .7vw, 7px);
  position: relative; display: grid; grid-template-columns: repeat(7, var(--cell)); grid-template-rows: repeat(6, var(--cell)); gap: var(--gap);
  padding: 13px; border: 1px solid rgba(75, 233, 210, .4); border-radius: 15px 15px 7px 7px;
  background: linear-gradient(135deg, rgba(18, 102, 139, .96), rgba(5, 66, 85, .98));
  box-shadow: inset 0 0 0 4px rgba(0, 15, 44, .2), inset 0 8px 25px rgba(89, 230, 214, .1), 0 18px 35px rgba(0, 4, 18, .43);
  touch-action: manipulation;
}
.board.thinking { cursor: wait; }
.cell { position: relative; width: var(--cell); aspect-ratio: 1; display: grid; place-items: center; border-radius: 50%; background: rgba(2, 18, 43, .9); box-shadow: inset 0 4px 11px rgba(0,0,0,.72), 0 1px rgba(145, 249, 231, .2); overflow: hidden; }
.cell::before { content: ""; position: absolute; inset: 6%; border-radius: 50%; border: 1px dashed rgba(80, 227, 200, .09); }
.cell.column-hover { background: rgba(4, 31, 57, .95); }
.token { position: absolute; width: 91%; height: 91%; object-fit: contain; border-radius: 50%; z-index: 1; user-select: none; -webkit-user-drag: none; }
.token.gold { filter: drop-shadow(0 2px 5px rgba(247, 193, 42, .52)); }
.token.silver { filter: drop-shadow(0 2px 5px rgba(76, 185, 242, .42)); }
.token.dropping { animation: token-drop .42s cubic-bezier(.25,.8,.35,1.16) both; }
@keyframes token-drop { from { transform: translateY(calc(var(--drop-rows, 6) * (var(--cell) + 7px) * -1)); } 75% { transform: translateY(4%); } to { transform: translateY(0); } }
.cell.winner .token { animation: winner-pulse .72s ease-in-out infinite alternate; }
.cell.winner::after { content: ""; position: absolute; inset: 2px; border: 2px solid var(--green); border-radius: 50%; z-index: 2; box-shadow: 0 0 17px var(--green); animation: ring 1s ease-out infinite; }
@keyframes winner-pulse { to { transform: scale(.9); filter: brightness(1.35) drop-shadow(0 0 10px var(--green)); } }
@keyframes ring { to { transform: scale(.83); opacity: .2; } }
.board-base { height: 12px; margin: 0 9px; border-radius: 0 0 12px 12px; background: linear-gradient(90deg, #0c536d, #118f86 50%, #0c536d); box-shadow: 0 7px 15px rgba(0,0,0,.3); display: flex; justify-content: space-between; padding: 8px 30px 0; }
.board-base span { width: 42px; height: 9px; background: #032039; border-radius: 0 0 8px 8px; }
.mobile-hint { display: none; margin-top: 13px; color: var(--muted); text-align: center; font-size: 11px; }

.command-panel { padding: 20px; border-radius: 24px 6px 24px 6px; display: flex; flex-direction: column; }
.section-title { display: flex; align-items: center; gap: 10px; margin-bottom: 13px; color: var(--green); font-size: 9px; font-weight: 900; letter-spacing: .19em; text-transform: uppercase; }
.section-title i { height: 1px; flex: 1; background: linear-gradient(90deg, var(--line), transparent); }
.scoreboard { display: grid; grid-template-columns: 1fr .7fr 1fr; gap: 8px; margin-bottom: 24px; }
.score-card { position: relative; min-height: 82px; border: 1px solid rgba(122, 219, 217, .13); background: rgba(1, 17, 40, .5); display: grid; place-items: center; align-content: center; border-radius: 5px 13px 5px 13px; overflow: hidden; }
.score-card img { position: absolute; width: 50px; left: -13px; bottom: -13px; opacity: .33; }
.silver-score img { left: auto; right: -13px; }
.score-card span { color: var(--muted); font-size: 8px; font-weight: 800; letter-spacing: .13em; }
.score-card strong { font-family: Georgia, serif; font-size: 29px; line-height: 1.1; }
.gold-score strong { color: var(--gold); }.silver-score strong { color: var(--silver); }.draw-score strong { color: var(--green); }
.difficulty-grid { display: grid; gap: 7px; }
.difficulty { width: 100%; display: flex; align-items: center; gap: 12px; padding: 9px; border: 1px solid rgba(119, 211, 211, .12); border-radius: 4px 13px 4px 13px; color: var(--ink); background: rgba(2, 18, 41, .42); text-align: left; cursor: pointer; transition: .18s ease; }
.difficulty:hover { border-color: rgba(70, 229, 154, .42); transform: translateX(3px); }
.difficulty.active { border-color: var(--green); background: linear-gradient(90deg, rgba(15, 123, 103, .35), rgba(5, 31, 59, .48)); box-shadow: inset 3px 0 var(--green), 0 0 20px rgba(55, 224, 170, .08); }
.rank { display: grid; place-items: center; width: 34px; aspect-ratio: 1; flex: 0 0 auto; transform: rotate(45deg); border: 1px solid rgba(242, 196, 81, .43); color: var(--gold); font-family: Georgia, serif; font-weight: 900; }
.rank::first-letter { transform: rotate(-45deg); }
.difficulty > span:last-child { display: flex; flex-direction: column; }
.difficulty b { font-size: 12px; letter-spacing: .025em; }.difficulty small { margin-top: 3px; color: var(--muted); font-size: 9px; }
.actions { margin-top: 18px; }
.primary-button { width: 100%; padding: 13px 15px; border: 1px solid #65efb6; border-radius: 4px 14px 4px 14px; color: #001d28; background: linear-gradient(120deg, #51e2a4, #52cfce); font-size: 11px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; cursor: pointer; box-shadow: 0 9px 25px rgba(43, 205, 164, .16); }
.primary-button:hover { filter: brightness(1.12); transform: translateY(-1px); }
.primary-button span { margin-right: 7px; font-size: 17px; }
.text-button { display: block; margin: 10px auto 0; border: 0; color: var(--muted); background: transparent; font-size: 9px; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.field-manual { margin-top: auto; padding-top: 17px; color: var(--muted); font-size: 10px; }
.field-manual summary { color: var(--silver); cursor: pointer; font-weight: 700; letter-spacing: .06em; }
.field-manual p { margin-bottom: 0; line-height: 1.6; }
footer { display: flex; justify-content: space-between; padding: 13px 5px 0; color: rgba(142, 183, 202, .55); font-size: 8px; letter-spacing: .14em; }

.toast { position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); z-index: 20; padding: 11px 18px; border: 1px solid rgba(71, 229, 157, .6); border-radius: 20px; color: var(--ink); background: rgba(2, 25, 45, .95); box-shadow: 0 10px 40px #0008; font-size: 11px; font-weight: 700; transform: translate(-50%, 25px); opacity: 0; pointer-events: none; transition: .25s ease; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.particle { position: fixed; z-index: 30; width: 8px; height: 14px; background: var(--color); left: var(--x); top: -20px; pointer-events: none; animation: fall var(--duration) cubic-bezier(.2,.7,.5,1) forwards; }
@keyframes fall { to { transform: translate(var(--drift), 105vh) rotate(720deg); opacity: 0; } }

@media (max-width: 930px) {
  :root { --cell: clamp(39px, 10.4vw, 68px); }
  .app-shell { width: min(760px, calc(100% - 22px)); }
  .game-layout { grid-template-columns: 1fr; }
  .command-panel { display: grid; grid-template-columns: 1fr 1.25fr; gap: 0 20px; }
  .difficulty-section { grid-row: span 2; }
  .actions { align-self: end; }
  .field-manual { grid-column: 1 / -1; }
}

@media (max-width: 620px) {
  :root { --cell: calc((100vw - 73px) / 7); }
  .app-shell { width: calc(100% - 14px); padding-top: 12px; }
  .masthead { gap: 11px; margin: 0 6px 12px; }
  .brand-mark { width: 49px; }.brand-mark span { font-size: 17px; }
  .eyebrow { font-size: 8px; letter-spacing: .15em; }
  h1 { font-size: clamp(24px, 8.2vw, 34px); }
  .subtitle { display: none; }.icon-button { width: 39px; }
  .battlefield { padding: 11px 7px 19px; border-radius: 5px 19px 5px 19px; }
  .status-row { min-height: 52px; padding: 0 6px 9px; gap: 9px; }
  .turn-token { width: 38px; }.status-copy span { font-size: 8px; }.status-copy strong { font-size: 13px; }
  .round-badge { font-size: 7px; }.round-badge span { font-size: 15px; }
  .board-wrap { margin-top: 8px; }
  .column-controls { gap: 3px; margin: 0 10px 5px; }
  .column-control { height: 23px; }
  .board { gap: 3px; padding: 10px; border-radius: 11px 11px 5px 5px; }
  .board-base { margin-inline: 6px; }
  .mobile-hint { display: block; }
  .command-panel { display: flex; padding: 16px; border-radius: 18px 5px 18px 5px; }
  .scoreboard { margin-bottom: 20px; }.score-card { min-height: 68px; }
  .difficulty-grid { grid-template-columns: 1fr 1fr; }
  .difficulty { gap: 8px; padding: 8px 7px; }
  .rank { width: 28px; font-size: 12px; }
  .difficulty b { font-size: 10px; }.difficulty small { display: none; }
  .actions { margin-top: 15px; }
  footer { flex-direction: column; align-items: center; gap: 4px; }
}

@media (max-width: 370px) {
  :root { --cell: calc((100vw - 59px) / 7); }
  .app-shell { width: calc(100% - 8px); }
  .board { padding: 7px; gap: 2px; }.column-controls { gap: 2px; margin-inline: 7px; }
  .brand-mark { display: none; }.difficulty-grid { grid-template-columns: 1fr; }
  .difficulty small { display: block; }
}

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