/* Tile Garden styles. Brand colors live in :root so the app is easy to re-skin. */
:root {
  --brand-1: #E8C766; --brand-2: #F4EEDC;
  --ivory-1: #FFFDF6; --ivory-2: #F7EEDA; --ivory-3: #E9DCBC;
  --bone-side: #E2D3AE; --gold: #C9A227; --gold-glow: #FFD54A;
  --back1: #2F8F6A; --back2: #17573F;
  --felt: #1F5E3D; --felt-dark: #0B2E1D;
  --ink: #FFFFFF; --panel: rgba(10, 30, 20, .62);
  --b-hint: #D9822B; --b-shuffle: #3B6FB6; --b-undo: #7A4FA8; --b-new: #2E8B57; --b-menu: #5A6470;
  --noise: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 .55 0'/></filter><rect width='160' height='160' filter='url(%23n)'/></svg>");
  --grain: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='120' height='120'><filter id='g'><feTurbulence type='fractalNoise' baseFrequency='.035 .6' numOctaves='2' seed='4'/><feColorMatrix values='0 0 0 0 .55  0 0 0 0 .42  0 0 0 0 .2  0 0 0 .22 0'/></filter><rect width='120' height='120' filter='url(%23g)'/></svg>");
}
body.theme-ocean { --felt: #17567F; --felt-dark: #06223A; --back1: #2B86B8; --back2: #154E73; --panel: rgba(5, 25, 45, .62); }
body.theme-sunset { --felt: #C2603F; --felt-dark: #4A1838; --back1: #C0563B; --back2: #7A2A3E; --panel: rgba(60, 15, 35, .6); }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink); min-height: 100vh; min-height: 100dvh; overflow-x: hidden;
  background: var(--noise), radial-gradient(ellipse at 50% 38%, var(--felt) 0%, var(--felt) 45%, var(--felt-dark) 120%);
  background-color: var(--felt-dark); background-attachment: fixed;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  -webkit-user-select: none; user-select: none;
}
#leaves { position: fixed; inset: 0; pointer-events: none; z-index: 0; opacity: .5;
  background:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 200'><g fill='%230E3B25'><path d='M0 0 Q70 10 110 60 Q60 50 0 30Z'/><path d='M0 20 Q40 60 50 120 Q20 80 0 70Z'/><path d='M20 0 Q80 -10 150 20 Q90 30 40 10Z'/></g><g fill='%23164D31'><path d='M0 40 Q60 40 90 90 Q40 80 0 60Z'/><path d='M40 0 Q70 30 70 80 Q50 40 30 10Z'/></g></svg>") top left / 260px no-repeat,
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 200'><g fill='%230E3B25' transform='rotate(180 100 100)'><path d='M0 0 Q70 10 110 60 Q60 50 0 30Z'/><path d='M0 20 Q40 60 50 120 Q20 80 0 70Z'/><path d='M20 0 Q80 -10 150 20 Q90 30 40 10Z'/></g><g fill='%23164D31' transform='rotate(180 100 100)'><path d='M0 40 Q60 40 90 90 Q40 80 0 60Z'/><path d='M40 0 Q70 30 70 80 Q50 40 30 10Z'/></g></svg>") bottom right / 260px no-repeat;
}
body:not(.theme-garden) #leaves { display: none; }
#app { position: relative; z-index: 1; max-width: 1280px; margin: 0 auto; padding: 10px 12px 24px; }
.bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.brand { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: clamp(28px, 6vw, 42px); letter-spacing: .5px; text-shadow: 0 2px 6px rgba(0,0,0,.5); }
.brand .b1 { color: var(--brand-1); } .brand .b2 { color: var(--brand-2); }
.stats { display: flex; gap: 8px; flex-wrap: wrap; }
.pill { background: var(--panel); border: 1px solid rgba(255,255,255,.25); border-radius: 999px; padding: 8px 16px; font-size: clamp(18px, 4.5vw, 24px); font-weight: 700; backdrop-filter: blur(4px); }
.controls { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.btn { font: inherit; font-size: clamp(18px, 4.6vw, 22px); font-weight: 800; color: #fff; min-height: 54px; min-width: 92px; padding: 10px 18px; border-radius: 16px; cursor: pointer;
  border: 1px solid rgba(255,255,255,.35); text-shadow: 0 1px 2px rgba(0,0,0,.45);
  background: linear-gradient(180deg, rgba(255,255,255,.28), rgba(255,255,255,0) 55%), var(--c, #444);
  box-shadow: 0 4px 0 rgba(0,0,0,.35), 0 8px 16px rgba(0,0,0,.3); transition: transform .08s, box-shadow .08s; }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0,0,0,.35), 0 3px 8px rgba(0,0,0,.3); }
.b-hint { --c: var(--b-hint); } .b-shuffle { --c: var(--b-shuffle); } .b-undo { --c: var(--b-undo); } .b-new { --c: var(--b-new); } .b-menu { --c: var(--b-menu); }
.panel { background: var(--panel); border: 1px solid rgba(255,255,255,.2); border-radius: 18px; padding: 12px; margin-bottom: 10px; backdrop-filter: blur(6px); }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 6px 0; font-size: 19px; }
.row.small { font-size: 17px; opacity: .95; line-height: 1.4; }
.lbl { font-weight: 700; min-width: 90px; }
.chip { font: inherit; font-size: 18px; font-weight: 700; min-height: 46px; padding: 8px 16px; border-radius: 999px; cursor: pointer; color: #fff; background: rgba(255,255,255,.12); border: 2px solid rgba(255,255,255,.35); }
.chip.on { background: var(--brand-1); color: #2A1E00; border-color: #fff; }
.msg { background: var(--panel); border: 2px solid var(--brand-1); border-radius: 16px; padding: 14px 16px; font-size: 21px; font-weight: 700; margin-bottom: 10px; animation: pop .35s ease-out; }
.msg .btn { margin-top: 10px; margin-right: 8px; }
#boardWrap { width: 100%; overflow: hidden; border-radius: 18px; }
#boardWrap.scroll { overflow: auto; -webkit-overflow-scrolling: touch; }
#board { position: relative; margin: 0 auto; }

/* Realistic tile: ivory face, sheen, grain, bone side and colored backing on the bottom-left edge, soft drop shadow. */
.tile { position: absolute; border-radius: calc(var(--tw) * .12); cursor: pointer; padding: calc(var(--tw) * .05);
  background: linear-gradient(155deg, var(--ivory-1) 0%, var(--ivory-2) 55%, var(--ivory-3) 100%);
  box-shadow:
    inset 1.5px 1.5px 0 rgba(255,255,255,.95), inset -1.5px -1.5px 2px rgba(150,120,60,.25),
    calc(var(--d) * -.4) calc(var(--d) * .4) 0 var(--bone-side),
    calc(var(--d) * -.62) calc(var(--d) * .62) 0 #D6C59A,
    calc(var(--d) * -.7) calc(var(--d) * .7) 0 var(--gold),
    calc(var(--d) * -1.05) calc(var(--d) * 1.05) 0 var(--back1),
    calc(var(--d) * -1.4) calc(var(--d) * 1.4) 0 var(--back2),
    calc(var(--d) * -1.8) calc(var(--d) * 2.6) calc(var(--d) * 3) rgba(0,0,0,.42);
  transition: transform .12s, filter .2s; }
.tile::before { content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: linear-gradient(145deg, rgba(255,255,255,.75) 0%, rgba(255,255,255,0) 32%), var(--grain); background-size: auto, 120px 120px; mix-blend-mode: multiply; opacity: .9; }
.tile::after { content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: linear-gradient(145deg, rgba(255,255,255,.55) 0%, rgba(255,255,255,0) 28%); }
.tile img { display: block; width: 100%; height: 100%; pointer-events: none; -webkit-user-drag: none; }
.tile.sel { transform: translateY(-3px); filter: drop-shadow(0 0 2px var(--gold-glow)) drop-shadow(0 0 7px var(--gold-glow)) drop-shadow(0 0 14px rgba(255,213,74,.7)); }
.tile.hint { animation: hintPulse 1s ease-in-out infinite; }
body.beginner .tile.blocked { filter: brightness(.6) saturate(.6); cursor: default; }
body.beginner .tile.free:not(.sel) { filter: drop-shadow(0 0 3px #9BFFC8) drop-shadow(0 0 1px #9BFFC8); }
.tile.shake { animation: shake .3s; }
.ghost { position: absolute; pointer-events: none; z-index: 99999; }
.ghost .tile { position: absolute; inset: 0; animation: popOut .6s ease-out forwards; filter: drop-shadow(0 0 10px var(--gold-glow)); }
.star { position: absolute; width: 16px; height: 16px; clip-path: polygon(50% 0,61% 39%,100% 50%,61% 61%,50% 100%,39% 61%,0 50%,39% 39%); animation: star .7s ease-out forwards; }
@keyframes popOut { 0% { transform: scale(1); opacity: 1; } 40% { transform: scale(1.18); opacity: 1; } 100% { transform: scale(.3) rotate(15deg); opacity: 0; } }
@keyframes star { 0% { transform: translate(0,0) scale(.4); opacity: 1; } 100% { transform: translate(var(--dx), var(--dy)) scale(1.2) rotate(180deg); opacity: 0; } }
@keyframes hintPulse { 0%,100% { filter: drop-shadow(0 0 3px #FFE27A) drop-shadow(0 0 6px #FFE27A); } 50% { filter: drop-shadow(0 0 6px #FFE27A) drop-shadow(0 0 16px #FFB300); } }
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
@keyframes pop { 0% { transform: scale(.7); opacity: 0; } 70% { transform: scale(1.04); opacity: 1; } 100% { transform: scale(1); } }
#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 100000; overflow: hidden; }
.conf { position: absolute; top: -20px; animation: fall linear infinite; }
@keyframes fall { 0% { transform: translateY(-5vh) rotate(0); } 100% { transform: translateY(110vh) rotate(720deg); } }
.modal { position: fixed; inset: 0; z-index: 100001; background: rgba(0,0,0,.55); display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal[hidden], .tip[hidden], .toast[hidden], .msg[hidden], .panel[hidden] { display: none; }
.sheet { background: #FFFBF0; color: #1E2B22; border-radius: 22px; padding: 20px; width: min(520px, 100%); max-height: 90vh; overflow: auto; box-shadow: 0 20px 50px rgba(0,0,0,.5); animation: pop .3s; }
.sheet h2 { margin: 0 0 12px; font-family: Georgia, serif; font-size: 28px; color: #17573F; }
.sheet label { display: block; font-size: 19px; font-weight: 700; margin: 12px 0 6px; }
.sheet textarea, .sheet input[type=text] { width: 100%; font: inherit; font-size: 19px; padding: 12px; border-radius: 12px; border: 2px solid #C9B98F; background: #fff; color: #1E2B22; }
.sheet textarea { min-height: 96px; }
.stars { display: flex; gap: 6px; }
.stars button { font-size: 42px; line-height: 1; width: 58px; height: 58px; border-radius: 14px; border: 2px solid #E2D3AE; background: #fff; color: #CFC5AE; cursor: pointer; }
.stars button.on { color: #E0A800; border-color: #E0A800; background: #FFF6D6; }
.sheet .actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.sheet .btn { color: #fff; }
.hp { position: absolute; left: -9999px; }
.tip { position: fixed; left: 12px; right: 12px; bottom: calc(14px + env(safe-area-inset-bottom)); z-index: 99999; background: #FFFBF0; color: #1E2B22; border-radius: 18px; padding: 16px; font-size: 19px; line-height: 1.4; box-shadow: 0 10px 30px rgba(0,0,0,.45); display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.tip > div { flex: 1 1 220px; }
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: #1E2B22; color: #fff; padding: 12px 20px; border-radius: 999px; font-size: 18px; z-index: 100003; box-shadow: 0 6px 18px rgba(0,0,0,.4); }
.landscape-hint { font-size: 16px; opacity: .9; }
@media (prefers-reduced-motion: reduce) { .tile.hint, .ghost .tile, .star, .conf { animation-duration: .01s !important; } }

/* ---- compact toolbar (v3) ---- */
#app { padding: calc(4px + env(safe-area-inset-top)) calc(4px + env(safe-area-inset-right)) 4px calc(4px + env(safe-area-inset-left)); }
.bar { flex-wrap: nowrap; gap: 6px; }
.brand { font-size: 22px; white-space: nowrap; }
.stats { gap: 6px; flex-wrap: nowrap; }
.pill { padding: 6px 10px; font-size: 17px; min-height: 40px; display: inline-flex; align-items: center; box-sizing: border-box; }
.controls { flex-wrap: nowrap; gap: 5px; margin: 5px 0; }
.controls .btn { flex: 1 1 0; min-width: 0; min-height: 44px; padding: 4px 4px; font-size: 16px; border-radius: 12px; display: inline-flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.1; }
.controls .btn i { font-style: normal; font-size: 17px; }
.install { font: inherit; font-size: 16px; font-weight: 800; min-height: 40px; padding: 4px 12px; border-radius: 999px; border: 2px solid #E8C766; background: #FFF6D6; color: #1E2B22; cursor: pointer; white-space: nowrap; }
.install[hidden] { display: none; }
@media (max-width: 430px) { .brand { font-size: 19px; } .install { font-size: 14px; padding: 2px 8px; } .pill { font-size: 15px; padding: 4px 8px; } }
@media (max-width: 359px) { .brand { display: none; } }
@media (orientation: landscape) and (max-height: 560px) {
  #app { display: grid; grid-template-columns: 172px 1fr; grid-template-rows: auto auto 1fr; column-gap: 8px; align-items: start; }
  .bar { grid-column: 1; grid-row: 1; flex-direction: column; align-items: stretch; gap: 5px; }
  .brand { font-size: 20px; display: block; } .stats { justify-content: space-between; }
  .install { font-size: 14px; padding: 2px 6px; white-space: normal; }
  .controls { grid-column: 1; grid-row: 2; display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }
  .controls .btn { flex-direction: row; gap: 4px; font-size: 15px; }
  #menu, #msg { grid-column: 1 / 3; grid-row: 3; }
  #boardWrap { grid-column: 2; grid-row: 1 / 4; }
}
.install-sheet h2 { font-size: 26px; }
.steps { list-style: none; counter-reset: s; padding: 0; margin: 0; }
.steps li { counter-increment: s; display: flex; align-items: center; gap: 14px; font-size: 21px; line-height: 1.35; padding: 12px 0; border-bottom: 1px solid #E8DCC0; }
.steps li::before { content: counter(s); flex: 0 0 38px; height: 38px; border-radius: 50%; background: #2E8B57; color: #fff; font-weight: 800; display: flex; align-items: center; justify-content: center; }
.sicon { flex: 0 0 56px; height: 56px; border-radius: 14px; background: #fff; border: 2px solid #E2D3AE; display: flex; align-items: center; justify-content: center; }
.addword { color: #1E6FD9; font-weight: 800; font-size: 20px; }

.safari-step { display: flex; align-items: center; gap: 14px; font-size: 19px; line-height: 1.35; padding: 10px 12px; margin-bottom: 4px; border-radius: 14px; background: #F3EEDF; }
.safari-step.loud { background: #FFF1C2; border: 3px solid #E0A800; font-size: 22px; }
.oldnote { display: flex; align-items: center; gap: 12px; font-size: 18px; color: #4A5A4F; margin: 10px 0 0; }
.sicon.small { flex-basis: 44px; height: 44px; }
/* ---- strong hint (v5): magenta outline + glow + tint, distinct from gold "selected" ---- */
.tile.hint { animation: hintPulse 1.1s ease-in-out infinite; z-index: 99990 !important; }
.tile.hint::after { content: ""; position: absolute; inset: -3px; border: 4px solid #FF1FA8; border-radius: 6px; background: rgba(255, 31, 168, .22);
  box-shadow: 0 0 0 2px #fff, 0 0 12px 4px rgba(255, 31, 168, .95); pointer-events: none; }
@keyframes hintPulse { 0%,100% { transform: translateY(0) scale(1); filter: drop-shadow(0 0 4px #FF1FA8); } 50% { transform: translateY(-3px) scale(1.07); filter: drop-shadow(0 0 14px #FF1FA8) drop-shadow(0 0 4px #fff); } }
