﻿/* Ripple — daily word puzzle. Mobile first: the whole game fits one screen. */
:root {
  --bg: #0a1826; --panel: #10243a; --panel-2: #163049; --line: #26415e; --text: #e9f2fb; --muted: #8aa4c0;
  --hit: #1fb6a6; --near: #8b7bff; --miss: #33475e; --accent: #5fd4ff;
  --key-h: 54px; --gap: 6px;
  --tile: min(62px, calc((100vw - 52px) / 5), calc((100dvh - 400px) / 6));
  font-family: Inter, system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { min-height: 100dvh; color: var(--text); -webkit-tap-highlight-color: transparent;
  background: radial-gradient(120% 60% at 50% 0%, #12345a 0%, transparent 60%), radial-gradient(80% 50% at 50% 100%, #0d2c3a 0%, transparent 70%), var(--bg); }
h1, h2, h3 { font-family: 'Space Grotesk', Inter, sans-serif; margin: 0; }
a { color: var(--accent); }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }

.app { display: flex; flex-direction: column; height: 100dvh; max-width: 540px; margin: 0 auto;
  padding: env(safe-area-inset-top) 8px max(8px, env(safe-area-inset-bottom)); }

/* ---------- header ---------- */
.top { display: flex; align-items: center; justify-content: space-between; gap: 8px; height: 52px; flex: none; border-bottom: 1px solid var(--line); }
.brand { text-align: center; line-height: 1.1; }
.brand h1 { font-size: 24px; letter-spacing: .02em; display: inline-flex; align-items: center; gap: 8px; }
.logo { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--hit); position: relative; }
.logo::before, .logo::after { content: ''; position: absolute; border-radius: 50%; border: 2px solid var(--hit); inset: 4px; opacity: .8; }
.logo::after { inset: -6px; opacity: .3; }
.day { font-size: 11px; color: var(--muted); letter-spacing: .06em; text-transform: uppercase; }
.top-btns { display: flex; gap: 6px; }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); display: grid; place-items: center;
  font-weight: 800; font-size: 18px; text-decoration: none; color: var(--text); }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn.back { font-size: 26px; padding-bottom: 3px; }

.play { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 6px; padding-top: 8px; }

/* ---------- ripple rings ---------- */
.ripples { flex: none; }
.rings { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
.ring { position: relative; display: flex; flex-direction: column; align-items: center; gap: 3px; background: none; border: 0; padding: 2px 0; color: var(--muted); min-width: 0; }
.ring .c { position: relative; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font: 700 15px 'Space Grotesk', sans-serif;
  border: 2px dashed var(--line); color: var(--muted); transition: background .3s, border-color .3s, color .3s; }
.ring .l { font-size: 11px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.ring.ready { color: var(--text); }
.ring.ready .c { border: 2px solid var(--hit); color: var(--hit); background: rgba(31, 182, 166, .14); }
.ring.ready .c::after { content: ''; position: absolute; inset: -2px; border-radius: 50%; border: 2px solid var(--hit); animation: ping 1.6s ease-out infinite; }
.ring.open .c { border: 2px solid var(--hit); background: var(--hit); color: #04211e; }
.ring.open.sel .c { box-shadow: 0 0 0 3px rgba(95, 212, 255, .55); }
.ring.open { color: var(--text); }
.ring:disabled { cursor: default; }
.clue { margin-top: 6px; min-height: 40px; padding: 6px 12px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line);
  font-size: 14px; line-height: 1.35; display: flex; align-items: center; gap: 8px; }
.clue b { color: var(--hit); white-space: nowrap; }
.clue.dim { color: var(--muted); }
.clue.flash { animation: flash .6s ease-out; }

/* ---------- board ---------- */
.board-wrap { position: relative; flex: 1; min-height: 0; display: grid; place-items: center; }
.board { display: grid; grid-template-rows: repeat(6, var(--tile)); gap: var(--gap); position: relative; z-index: 1; }
.row { display: grid; grid-template-columns: repeat(5, var(--tile)); gap: var(--gap); }
.row.shake { animation: shake .4s; }
.tile { border: 2px solid var(--line); border-radius: 10px; display: grid; place-items: center; user-select: none;
  font: 700 calc(var(--tile) * .52) 'Space Grotesk', sans-serif; text-transform: uppercase; background: rgba(10, 24, 38, .6); }
.tile.filled { border-color: #6b8db0; animation: pop .1s ease-out; }
.tile.ghost { color: rgba(31, 182, 166, .55); border-style: dashed; border-color: rgba(31, 182, 166, .55); }
.tile.hit, .tile.near, .tile.miss { border-color: transparent; color: #fff; }
.tile.hit { background: var(--hit); color: #04211e; }
.tile.near { background: var(--near); }
.tile.miss { background: var(--miss); color: #c6d4e3; }
.tile.flip { animation: flip .5s ease-in-out both; }
.tile.win { animation: bounce .6s ease both; }

/* expanding rings behind the board when a ripple unlocks */
.wave { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.wave i { position: absolute; left: 50%; top: 50%; width: 80px; height: 80px; margin: -40px 0 0 -40px; border-radius: 50%;
  border: 3px solid var(--hit); opacity: 0; animation: wave 1.6s ease-out forwards; }
.wave i:nth-child(2) { animation-delay: .2s; } .wave i:nth-child(3) { animation-delay: .4s; }

/* ---------- keyboard ---------- */
.keyboard { flex: none; display: flex; flex-direction: column; gap: 7px; padding-bottom: 2px; user-select: none; }
.krow { display: flex; gap: 5px; justify-content: center; }
.key { flex: 1 1 0; max-width: 46px; height: var(--key-h); border: 0; border-radius: 8px; background: #3a5674; color: var(--text);
  font-weight: 700; font-size: 16px; text-transform: uppercase; display: grid; place-items: center; padding: 0; }
.key.wide { max-width: 72px; flex-grow: 1.6; font-size: 12px; letter-spacing: .04em; }
.key:active { filter: brightness(1.25); }
.key.hit { background: var(--hit); color: #04211e; }
.key.near { background: var(--near); }
.key.miss { background: #1f3044; color: #6f86a0; }
.key svg { width: 22px; height: 22px; }
.krow .spacer { flex: .5 1 0; max-width: 23px; }

/* ---------- toast ---------- */
.toast { position: fixed; left: 50%; top: max(190px, 26dvh); transform: translateX(-50%); z-index: 60; background: #f1f6fb; color: #0a1826; font-weight: 700;
  padding: 10px 18px; border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.35); opacity: 0; pointer-events: none; transition: opacity .2s; max-width: 90vw; text-align: center; }
.toast.show { opacity: 1; }

/* ---------- modals ---------- */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 14px; background: rgba(3, 10, 18, .72); backdrop-filter: blur(3px); }
.modal-box { position: relative; width: min(460px, 100%); max-height: calc(100dvh - 28px); overflow: auto; background: var(--panel); border: 1px solid var(--line);
  border-radius: 18px; padding: 22px 20px 16px; box-shadow: 0 24px 60px rgba(0,0,0,.5); animation: rise .25s ease-out; line-height: 1.5; }
.modal-box h2 { font-size: 24px; margin-right: 40px; }
.modal-box h3 { font-size: 16px; margin: 14px 0 6px; }
.modal-box p { margin: 8px 0; }
.close { position: absolute; top: 12px; right: 12px; width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel-2); font-size: 15px; }
.tag { color: var(--hit); font-weight: 600; margin-top: 2px !important; }
.btn { border: 1px solid var(--line); background: var(--panel-2); border-radius: 12px; padding: 12px 18px; font-weight: 700; }
.btn.primary { background: linear-gradient(135deg, #1fb6a6, #35d0e0); color: #04211e; border: 0; }
.btn.wide { display: block; width: 100%; margin-top: 14px; }
.ex { background: var(--bg); border-radius: 12px; padding: 12px; margin: 10px 0; }
.ex-row { display: flex; gap: 5px; margin-bottom: 6px; --tile: 40px; }
.ex-row .t { width: 40px; height: 40px; border-radius: 8px; border: 2px solid var(--line); display: grid; place-items: center; font: 700 20px 'Space Grotesk', sans-serif; }
.ex-row .t.hit { background: var(--hit); border-color: var(--hit); color: #04211e; }
.ex-row .t.near { background: var(--near); border-color: var(--near); }
.ex ul { list-style: none; padding: 0; margin: 0; font-size: 14px; }
.ex li { display: flex; align-items: center; gap: 8px; margin: 4px 0; }
.dot { width: 14px; height: 14px; border-radius: 4px; flex: none; }
.dot.hit { background: var(--hit); } .dot.near { background: var(--near); } .dot.miss { background: var(--miss); }
.ripple-list { padding-left: 22px; margin: 6px 0; } .ripple-list li { margin: 3px 0; }
.ripple-list b { color: var(--hit); }

.result { text-align: center; padding-bottom: 6px; border-bottom: 1px solid var(--line); margin-bottom: 8px; }
.result h2 { margin: 0 !important; font-size: 28px; }
.answer span { display: block; font: 700 30px 'Space Grotesk', sans-serif; letter-spacing: .25em; color: var(--hit); text-transform: uppercase; }
.answer small { color: var(--muted); font-size: 14px; }
.sub { font-size: 13px !important; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin: 12px 0 6px !important; }
.nums { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; text-align: center; }
.nums b { display: block; font: 700 28px 'Space Grotesk', sans-serif; }
.nums span { font-size: 11px; color: var(--muted); }
.dist { display: grid; gap: 4px; }
.bar { display: grid; grid-template-columns: 14px 1fr; gap: 8px; align-items: center; font-size: 13px; font-weight: 700; }
.bar i { display: block; min-width: 26px; background: var(--miss); border-radius: 6px; padding: 2px 8px; text-align: right; font-style: normal; transition: width .5s; }
.bar.today i { background: var(--hit); color: #04211e; }
.avg { color: var(--muted); font-size: 13px; text-align: center; }
.share-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 14px 0 6px; padding-top: 12px; border-top: 1px solid var(--line); }
.next span { display: block; font-size: 12px; color: var(--muted); }
.next b { font: 700 24px 'Space Grotesk', sans-serif; font-variant-numeric: tabular-nums; }
#btn-share { flex: 1; max-width: 200px; font-size: 16px; }
.ad-wrap { width: 100%; text-align: center; margin-top: 10px; }
.ad-wrap.ad-on { min-height: 100px; }
.ad-wrap:has(ins[data-ad-status="unfilled"]) { display: none; }
.ad-label { font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.more { text-align: center; font-size: 13px; color: var(--muted); }
.site-footer { text-align: center; color: var(--muted); font-size: 13px; padding: 16px; }
.nojs { text-align: center; padding: 20px; }

/* ---------- shorter phones ---------- */
@media (max-height: 700px) {
  :root { --key-h: 46px; --gap: 5px; --tile: min(62px, calc((100vw - 52px) / 5), calc((100dvh - 352px) / 6)); }
  .top { height: 46px; }
  .ring .c { width: 32px; height: 32px; font-size: 14px; }
  .clue { min-height: 36px; font-size: 13px; padding: 4px 10px; }
  .keyboard { gap: 6px; }
}

/* ---------- phones held sideways: board left, clues and keyboard right ---------- */
@media (orientation: landscape) and (max-height: 520px) {
  :root { --key-h: 40px; --gap: 4px; --tile: min(56px, calc((100dvh - 92px) / 6)); }
  .app { max-width: 900px; }
  .top { height: 44px; }
  .play { display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: auto 1fr; column-gap: 18px; row-gap: 6px; padding-top: 6px; }
  .board-wrap { grid-row: 1 / 3; grid-column: 1; }
  .ripples { grid-column: 2; }
  .keyboard { grid-column: 2; align-self: end; gap: 5px; }
  .ring .c { width: 30px; height: 30px; font-size: 13px; }
  .clue { min-height: 34px; font-size: 13px; padding: 4px 10px; }
  .toast { top: 46%; }
}

/* ---------- desktop: a little more room ---------- */
@media (min-height: 860px) and (min-width: 600px) {
  :root { --tile: min(66px, calc((100dvh - 420px) / 6)); --key-h: 58px; }
}

@keyframes pop { 50% { transform: scale(1.1); } }
@keyframes flip { 0% { transform: rotateX(0); } 50% { transform: rotateX(90deg); } 100% { transform: rotateX(0); } }
@keyframes bounce { 0%, 100% { transform: translateY(0); } 40% { transform: translateY(-30%); } 70% { transform: translateY(4%); } }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
@keyframes ping { 0% { transform: scale(1); opacity: .8; } 100% { transform: scale(1.7); opacity: 0; } }
@keyframes wave { 0% { transform: scale(.4); opacity: .7; } 100% { transform: scale(7); opacity: 0; } }
@keyframes flash { 0% { background: rgba(31, 182, 166, .35); } 100% { background: var(--panel); } }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }
@media (prefers-reduced-motion: reduce) {
  .tile.flip, .tile.win, .wave i, .ring.ready .c::after { animation: none; }
}
