/* Phone first: thumb-sized targets, controls at the bottom, light colours. */
:root {
  color-scheme: light;
  --ink: #231a3a; --muted: #5d5475; --accent: #5532b8;
  --surface: #ffffff; --soft: #f1edf9; --line: #ded7ee;
  --good: #08734c; --bad: #b81239; --sun: #ffd23f;
  --dock: 136px;
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px); --safe-r: env(safe-area-inset-right, 0px);
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { height: 100%; overflow: hidden; overscroll-behavior: none; }
body {
  font-family: system-ui, "PingFang HK", "Microsoft JhengHei", sans-serif;
  color: var(--ink); background: radial-gradient(circle at 50% 20%, #ffffff, #dbe7f6 80%);
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
#app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; padding: 0 var(--safe-r) 0 var(--safe-l); }
button, .button {
  font: inherit; font-weight: 800; font-size: 16px; border: 0; border-radius: 14px; padding: 10px 14px;
  min-height: 48px; min-width: 48px; cursor: pointer; color: var(--ink); touch-action: manipulation;
}
button:disabled { opacity: .4; cursor: default; }
button:active:not(:disabled) { transform: translateY(2px); }
button:focus-visible, a:focus-visible, summary:focus-visible, input:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.primary { background: var(--sun); color: var(--ink); box-shadow: 0 4px 0 #c99a0a; }
.ghost { background: var(--soft); box-shadow: inset 0 0 0 1px var(--line); }
.big { width: 100%; font-size: 20px; min-height: 56px; }

/* ---------- play screen ---------- */
#hud { display: flex; align-items: stretch; justify-content: space-between; gap: 4px; padding: calc(6px + var(--safe-t)) 8px 6px; background: var(--surface); border-bottom: 1px solid var(--line); }
#hud > button:not(.stat) { white-space: nowrap; padding: 8px 12px; }
#quit.armed { background: var(--bad); color: #fff; }
.stat { display: flex; flex-direction: column; justify-content: center; text-align: center; min-width: 44px; line-height: 1.2; }
.stat small { font-size: 11px; color: var(--muted); white-space: nowrap; }
.stat b { font-size: 20px; font-variant-numeric: tabular-nums; }
button.stat { background: var(--soft); box-shadow: inset 0 0 0 1px var(--line); padding: 2px 8px; min-width: 56px; }
.stat i { display: block; height: 4px; background: var(--line); border-radius: 2px; overflow: hidden; }
.stat u { display: block; height: 100%; width: 0; background: #12a06c; transition: width .3s; }
#time.urgent { color: var(--bad); animation: pulse .5s infinite alternate; }
@keyframes pulse { to { transform: scale(1.2); } }

#stage { flex: 1; position: relative; min-height: 0; }
#view { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
#tools { position: absolute; right: 8px; top: 8px; display: flex; flex-direction: column; gap: 8px; }
#tools button { font-size: 12px; padding: 4px 8px; min-width: 56px; background: #ffffffe6; }
#toast {
  position: absolute; left: 8px; right: 76px; top: 8px; width: max-content; max-width: calc(100% - 84px); margin: 0 auto;
  background: #231a3aee; color: #fff; padding: 8px 14px; border-radius: 18px; font-size: 14px; text-align: center;
  opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 20;
}
#toast.on { opacity: 1; }
#why { position: absolute; left: 0; right: 0; bottom: 8px; text-align: center; pointer-events: none; color: var(--bad); font-weight: 800; font-size: 16px; text-shadow: 0 0 4px #fff, 0 0 4px #fff, 0 0 8px #fff; }
/* Mouse users only: phones and tablets use the rotate button. */
#mouseHint { display: none; }
@media (hover: hover) and (pointer: fine) {
  #mouseHint { display: block; position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); width: max-content; max-width: calc(100% - 16px); padding: 8px 16px; border-radius: 20px; background: var(--accent); color: #fff; font-size: 15px; font-weight: 800; text-align: center; pointer-events: none; box-shadow: 0 4px 14px #231a3a33; }
  #why { bottom: 56px; }
}
#visitTop { position: absolute; left: 8px; right: 76px; top: 8px; background: #ffffffee; border-radius: 14px; padding: 8px 12px; box-shadow: 0 4px 14px #231a3a26; font-size: 13px; }
#visitTop b { display: block; font-size: 16px; }

/* The dock keeps one height, so the flat never jumps when its contents change. */
#dock { flex: 0 0 calc(var(--dock) + var(--safe-b)); padding-bottom: var(--safe-b); background: var(--surface); border-top: 1px solid var(--line); min-height: 0; }
#tray { display: flex; gap: 8px; height: 100%; overflow-x: auto; padding: 10px; scroll-snap-type: x proximity; overscroll-behavior: contain; scrollbar-width: none; }
.card { position: relative; flex: 0 0 90px; scroll-snap-align: start; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; background: var(--soft); box-shadow: inset 0 0 0 1px var(--line); padding: 6px 4px; }
.card i { font-size: 34px; font-style: normal; line-height: 1.2; }
.card b { font-size: 13px; white-space: nowrap; }
.card small { font-size: 11px; color: var(--muted); font-weight: 400; }
.card em { position: absolute; top: 3px; right: 5px; min-width: 20px; border-radius: 10px; background: var(--accent); color: #fff; font-style: normal; font-size: 12px; line-height: 20px; }

#controls, #visitBar { display: grid; gap: 10px; height: 100%; padding: 10px; grid-template-rows: 1fr 1fr; }
#controls { grid-template-columns: repeat(10, 1fr); }
#controls .nudge { grid-column: span 2; font-size: 20px; touch-action: none; }
#rotate { grid-column: span 2; font-size: 20px; }
#cancel { grid-column: span 4; }
#place { grid-column: span 6; font-size: 20px; }
#visitBar { grid-template-columns: 1fr 1fr; }
#accept2 { grid-column: 1 / -1; font-size: 19px; }

/* ---------- sheets and screens ---------- */
#list { position: absolute; left: 8px; right: 8px; top: 8px; max-width: 380px; margin: 0 auto; max-height: calc(100% - 16px); overflow-y: auto; overscroll-behavior: contain; background: #fffffffa; border-radius: 16px; padding: 12px; box-shadow: 0 10px 30px #231a3a33; z-index: 5; }
#list header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.needs ul { list-style: none; padding: 0; text-align: left; font-size: 14px; line-height: 1.5; }
.needs li { display: flex; justify-content: space-between; gap: 8px; padding: 3px 0; }
.needs li.bad { color: var(--bad); }
.needs h3 { margin: 6px 0 2px; }
.radar { display: block; width: 100%; max-width: 320px; margin: 0 auto; overflow: visible; }
.radar .grid { fill: none; stroke: #231a3a1a; stroke-width: 1; }
.radar .rim { fill: #231a3a05; stroke: #231a3a59; stroke-width: 1; }
.radar .area { fill: #12a06c33; stroke: #08734c; stroke-width: 2; stroke-linejoin: round; }
.radar .dot { fill: #08734c; stroke: #fff; stroke-width: 2; }
.radar .name { font-size: 14px; font-weight: 800; fill: var(--ink); }
.radar .value { font-size: 12px; fill: var(--muted); font-variant-numeric: tabular-nums; }
.radar .full .value { fill: var(--good); font-weight: 800; }

.overlay { position: fixed; inset: 0; overflow-y: auto; overscroll-behavior: contain; display: flex; background: #dbe7f6cc; backdrop-filter: blur(4px); padding: calc(10px + var(--safe-t)) calc(10px + var(--safe-r)) calc(10px + var(--safe-b)) calc(10px + var(--safe-l)); z-index: 10; }
.panel { margin: auto; width: min(460px, 100%); background: var(--surface); border-radius: 24px; padding: 18px 14px; text-align: center; box-shadow: 0 20px 60px #231a3a26; position: relative; }
.corner { display: flex; justify-content: flex-end; gap: 8px; margin: -6px -2px 4px 0; }
h1 { font-size: clamp(32px, 11vw, 42px); color: var(--accent); text-shadow: 0 4px 0 #ffd23f99; }
h2 { font-size: 26px; color: var(--accent); }
h3 { font-size: 13px; color: var(--muted); margin-top: 6px; }
.tagline { margin: 6px 0 14px; color: var(--muted); }
#levels { display: flex; flex-direction: column; gap: 10px; }
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; background: var(--soft); border-radius: 16px; box-shadow: inset 0 0 0 1px var(--line); }
.modes button { background: none; color: var(--muted); }
.modes button[aria-pressed="true"] { background: var(--accent); color: #fff; }
.level { text-align: left; background: var(--soft); box-shadow: inset 0 0 0 1px var(--line); display: flex; flex-direction: column; gap: 3px; padding: 12px 14px; }
.level b { font-size: 19px; }
.level span { font-size: 14px; color: var(--good); }
.level small { font-size: 12px; font-weight: 400; color: var(--muted); }
.level.daily { background: linear-gradient(120deg, #ffe0ec, #e9dcff); box-shadow: inset 0 0 0 2px #b79cf0; }
#friend { background: #fff0b8; border-radius: 16px; padding: 14px; margin-bottom: 12px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
#friend b, #friend p { grid-column: 1 / -1; }
#friend .primary { background: var(--accent); color: #fff; box-shadow: none; }
#friend .ghost { background: #fff; }
details { margin-top: 6px; text-align: left; font-size: 14px; color: var(--muted); }
summary { cursor: pointer; text-align: center; font-weight: 800; padding: 14px; }
ol { padding: 0 0 0 20px; line-height: 1.7; }

#versus { color: var(--good); font-weight: 800; }
#rank { font-size: 30px; font-weight: 900; color: #c01f63; }
#summary { font-size: 14px; margin: 4px 0 10px; }
#cardBtn { display: block; width: 100%; padding: 0; background: none; border-radius: 16px; }
#cardImg { display: block; width: 100%; border-radius: 16px; box-shadow: 0 4px 18px #231a3a2e; -webkit-user-select: auto; user-select: auto; -webkit-touch-callout: default; }
.hint { font-size: 12px; color: var(--muted); margin: 6px 0 10px; }
/* The main action stays under the thumb while the player scrolls the report. */
#shareDock { position: sticky; bottom: 0; z-index: 2; padding: 8px 0; background: linear-gradient(#ffffff00, #fff 30%); }
#socials { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 2px 0 10px; }
#socials a { display: flex; align-items: center; justify-content: center; min-height: 48px; border-radius: 12px; font-weight: 800; text-decoration: none; font-size: 13px; padding: 0 2px; background: #333; color: #fff; }
#socials .whatsapp { background: #1f7d46; }
#socials .facebook { background: #1465d1; }
#socials .x, #socials .threads { background: #000; }
.linkbox { background: #fff0b8; border-radius: 16px; padding: 12px; margin-bottom: 10px; }
.linkbox b { display: block; margin-bottom: 8px; }
.linkbox input { width: 100%; min-height: 44px; border: 1px solid #c99a0a; border-radius: 10px; padding: 0 10px; font: inherit; font-size: 16px; color: var(--muted); background: #fff; user-select: text; -webkit-user-select: text; text-overflow: ellipsis; }
.row { display: flex; gap: 8px; margin-top: 8px; }
.row > * { flex: 1; }
a.button { display: flex; align-items: center; justify-content: center; text-decoration: none; }
#report { background: var(--soft); border-radius: 12px; padding: 8px 12px; margin: 10px 0; }
.discord { display: block; margin-top: 12px; padding: 12px 14px; border-radius: 14px; background: #4752c4; color: #fff; text-align: center; text-decoration: none; }
.discord:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
.discord b { display: block; font-size: 17px; }
.discord small { font-size: 13px; }
#zoomCard { position: fixed; inset: 0; z-index: 30; border-radius: 0; background: #231a3af2; padding: calc(8px + var(--safe-t)) 8px calc(8px + var(--safe-b)); display: flex; align-items: center; justify-content: center; }
#zoomCard img { max-width: 100%; max-height: 100%; border-radius: 12px; -webkit-touch-callout: default; }
#zoomCard:active { transform: none; }

@media (hover: hover) {
  .level:hover { background: #e6defa; }
  .level.daily:hover { background: linear-gradient(120deg, #ffd3e4, #dfceff); }
  .discord:hover { background: #3a44ab; }
}
@media (max-width: 360px) {
  .stat { min-width: 36px; }
  .stat b { font-size: 17px; }
  .stat small { font-size: 10px; }
  button.stat { min-width: 48px; padding: 2px 4px; }
  #hud > button:not(.stat) { padding: 8px; font-size: 14px; }
}
/* Phone held sideways: the dock moves to the right-hand side. */
@media (orientation: landscape) and (max-height: 520px) {
  #app { display: grid; grid-template-columns: minmax(0, 1fr) 244px; grid-template-rows: auto minmax(0, 1fr); }
  #hud { grid-column: 1 / -1; }
  #stage { grid-column: 1; grid-row: 2; }
  #dock { grid-column: 2; grid-row: 2; border-top: 0; border-left: 1px solid var(--line); }
  #tray { display: grid; grid-template-columns: 1fr 1fr; grid-auto-rows: 92px; overflow: hidden auto; }
  #controls { grid-template-columns: repeat(4, 1fr); grid-template-rows: repeat(4, 1fr); }
  #controls .nudge { grid-column: span 1; }
  #rotate, #cancel, #place { grid-column: 1 / -1; }
  #visitBar { grid-template-columns: 1fr; grid-template-rows: repeat(3, minmax(48px, 64px)); align-content: center; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
#zoomCard::after { content: "✕"; position: absolute; top: calc(10px + var(--safe-t)); right: 14px; width: 44px; height: 44px; border-radius: 50%; background: #fff; color: var(--ink); font-size: 20px; line-height: 44px; }
