/* Side by Sweet: styles for the HTML screens over the game canvas. Phones first, portrait first.
   Colours come from the theme through CSS variables set by the page (see applyTheme in src/ui/main.js). */

:root {
  --bg-top: #ffe3ec;
  --bg-bottom: #fff4e4;
  --text: #4a2335;
  --muted: #86566b;
  --accent: #d63a64;
  --accent-ink: #ffffff;
  --line: #f0b5c6;
  --a: #e69f00;
  --b: #0072b2;
  --gold: #f2b33d;
  --card: #ffffff;
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, 'Noto Sans Myanmar', 'Myanmar Text', 'Myanmar Sangam MN', Padauk, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--bg-top);
  color: var(--text);
  font-family: var(--font);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

:lang(my) {
  line-height: 1.6;
}

/* Burmese letters stack taller: every control and heading gets the same room in Burmese. */
:lang(my) h1,
:lang(my) h2,
:lang(my) h3,
:lang(my) .btn,
:lang(my) .chip,
:lang(my) .tab,
:lang(my) .back,
:lang(my) .text,
:lang(my) .select,
:lang(my) .theme-pick,
:lang(my) .avatar-pick {
  line-height: 1.6;
}

.app {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

.game {
  position: absolute;
  left: 0;
  top: 0;
  display: block;
  touch-action: none;
}

/* Buttons over the play canvas: pause (44 px) and the emote heart (48 px). */
.hud {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  pointer-events: none;
}

.hud[hidden],
.hud button[hidden] {
  display: none;
}

.hud button {
  position: absolute;
  pointer-events: auto;
  touch-action: manipulation;
  padding: 0;
  margin: 0;
  border: 0;
  cursor: pointer;
}

.hud-pause {
  background: transparent;
}

.pause-icon {
  position: absolute;
  left: 14px;
  top: 9px;
  width: 18px;
  height: 18px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 0 0 2px var(--line);
}

.pause-icon::before,
.pause-icon::after {
  content: '';
  position: absolute;
  top: 4px;
  width: 3px;
  height: 10px;
  border-radius: 2px;
  background: var(--text);
}

.pause-icon::before {
  left: 5px;
}

.pause-icon::after {
  right: 5px;
}

.hud-emote {
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 0 0 2px var(--b), 0 3px 8px rgba(80, 20, 50, 0.18);
}

.hud-emote:active {
  transform: scale(0.94);
}

.heart-icon {
  position: absolute;
  left: 50%;
  top: 52%;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  background: var(--accent);
  transform: rotate(45deg);
}

.heart-icon::before,
.heart-icon::after {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
}

.heart-icon::before {
  left: -7px;
  top: 0;
}

.heart-icon::after {
  left: 0;
  top: -7px;
}

/* The HTML screens. */
.screen {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
  background: linear-gradient(var(--bg-top), var(--bg-bottom));
}

.screen.empty {
  display: none;
}

.screen.over {
  background: rgba(70, 25, 45, 0.3);
}

.page {
  max-width: 480px;
  margin: 0 auto;
  padding: 14px 16px 36px;
}

.top {
  display: flex;
  min-height: 44px;
  align-items: center;
}

.back {
  min-height: 44px;
  padding: 6px 12px 6px 4px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: 700 15px/1.3 var(--font);
  cursor: pointer;
}

.back::before {
  content: '';
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-right: 8px;
  border-left: 2.5px solid currentColor;
  border-bottom: 2.5px solid currentColor;
  transform: rotate(45deg);
  vertical-align: 1px;
}

h1,
h2,
h3 {
  margin: 8px 0 10px;
  line-height: 1.3;
}

h2 {
  font-size: 24px;
  font-weight: 900;
}

h3 {
  font-size: 16px;
  color: var(--muted);
}

.lead {
  margin: 0 0 14px;
  font-size: 15px;
}

.hint,
.note,
.made {
  color: var(--muted);
  font-size: 13px;
}

.stack {
  display: grid;
  gap: 10px;
  margin: 16px 0;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin: 12px 0;
}

.row .btn {
  flex: 1 1 140px;
}

.btn {
  display: block;
  width: 100%;
  min-height: 48px;
  padding: 10px 16px;
  border: 2px solid var(--line);
  border-radius: 16px;
  background: var(--card);
  color: var(--text);
  font: 700 16px/1.3 var(--font);
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
  box-shadow: 0 2px 0 rgba(120, 40, 70, 0.08);
}

.btn:active {
  transform: translateY(1px);
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.btn.big {
  min-height: 56px;
  font-size: 18px;
}

.btn.small {
  min-height: 44px;
  padding: 8px 10px;
  font-size: 14px;
}

.btn.ghost {
  background: transparent;
  box-shadow: none;
}

a.btn {
  display: flex;
  align-items: center;
  justify-content: center;
}

.chip {
  min-height: 44px;
  padding: 8px 16px;
  border: 2px solid var(--line);
  border-radius: 22px;
  background: var(--card);
  color: var(--text);
  font: 700 15px/1.3 var(--font);
  cursor: pointer;
}

/* Title */
.title-page {
  text-align: center;
  padding-top: 24px;
}

.title-art {
  display: flex;
  justify-content: center;
}

.title-name {
  margin: 4px 0 0;
  color: var(--accent);
  font-size: 40px;
  font-weight: 900;
  letter-spacing: 0.5px;
}

.logo {
  display: block;
  max-width: 80%;
  max-height: 140px;
  margin: 4px auto 0;
}

/* Kept for screen readers, hidden on screen. */
.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.title-local {
  margin: 0;
  font-size: 28px;
  font-weight: 800;
  line-height: 1.7;
}

.title-tagline {
  margin: 2px 0 6px;
  color: var(--muted);
  font-weight: 700;
}

.settings-row {
  justify-content: center;
}

/* Switches */
.switch {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 6px 4px;
  cursor: pointer;
}

.switches .switch {
  border-bottom: 1px solid rgba(200, 120, 150, 0.2);
}

.switch-text {
  display: flex;
  flex: 1;
  flex-direction: column;
  text-align: left;
  font-weight: 700;
}

.switch-note {
  color: var(--muted);
  font-weight: 500;
}

.switch-state {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.switch-input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.switch-track {
  position: relative;
  flex: none;
  width: 48px;
  height: 28px;
  border-radius: 14px;
  background: #e7d2da;
  transition: background 0.15s;
}

.switch-track::after {
  content: '';
  position: absolute;
  left: 3px;
  top: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  transition: transform 0.15s;
}

.switch-input:checked + .switch-track {
  background: var(--accent);
}

.switch-input:checked + .switch-track::after {
  transform: translateX(20px);
}

.switch-input:focus-visible + .switch-track {
  outline: 3px solid var(--b);
  outline-offset: 2px;
}

/* Our pair */
.field {
  display: block;
  margin: 14px 0;
}

.label {
  display: block;
  margin-bottom: 6px;
  font-weight: 800;
}

.text,
.select {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border: 2px solid var(--line);
  border-radius: 14px;
  background: #ffffff;
  color: var(--text);
  font: 600 17px/1.4 var(--font);
  -webkit-user-select: text;
  user-select: text;
}

.themes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.theme-pick,
.avatar-pick {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 6px;
  border: 2px solid var(--line);
  border-radius: 16px;
  background: #ffffff;
  color: var(--text);
  font: 700 14px/1.3 var(--font);
  cursor: pointer;
}

.theme-pick canvas {
  max-width: 100%;
  height: auto !important;
}

.theme-pick.on,
.avatar-pick.on {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(214, 58, 100, 0.2);
}

.theme-note {
  color: var(--muted);
  font-weight: 500;
}

.avatars {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.avatar-name {
  font-size: 12px;
}

.check {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  font-weight: 700;
}

.check input {
  width: 22px;
  height: 22px;
  accent-color: var(--accent);
}

/* How to play */
.howto {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.howto-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 18px;
  background: #ffffff;
  box-shadow: 0 2px 10px rgba(120, 40, 70, 0.08);
}

.howto-card p {
  margin: 0;
  font-weight: 600;
}

.howto-n {
  position: absolute;
  left: -6px;
  top: -6px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent);
  color: #ffffff;
  font-weight: 900;
  line-height: 26px;
  text-align: center;
}

.howto-card canvas {
  flex: none;
}

/* Letters */
.letters {
  display: grid;
  gap: 12px;
  margin: 12px 0;
  padding: 0;
  list-style: none;
}

.letter {
  padding: 12px;
  border-radius: 18px;
  background: #ffffff;
  box-shadow: 0 2px 10px rgba(120, 40, 70, 0.08);
}

.letter-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.letter-text {
  flex: 1;
  min-width: 0;
}

.letter-n {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.letter-place {
  font-size: 18px;
  font-weight: 900;
}

.letter-teach {
  color: var(--muted);
  font-size: 13px;
}

.letter-buttons {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 8px;
  margin-top: 10px;
}

.stars {
  display: inline-flex;
  gap: 1px;
}

.star::before {
  content: '\2605';
  color: #e9d8de;
  font-size: 18px;
}

.star.on::before {
  color: var(--gold);
}

/* Pause and result sheets over the game. */
.overlay {
  display: flex;
  min-height: 100%;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.sheet {
  width: 100%;
  max-width: 420px;
  padding: 16px 18px 8px;
  border-radius: 24px;
  background: #ffffff;
  box-shadow: 0 10px 40px rgba(70, 20, 45, 0.25);
  text-align: center;
}

.sheet .switches {
  text-align: left;
}

.result h2 {
  font-size: 26px;
  color: var(--accent);
}

.result.lost h2 {
  color: var(--text);
}

.reason {
  margin: 0 0 4px;
  font-weight: 700;
}

.together,
.best {
  margin: 0 0 6px;
  color: var(--gold);
  font-weight: 900;
}

.result .stars .star::before {
  font-size: 34px;
}

.score-label {
  margin-top: 6px;
  color: var(--muted);
  font-weight: 700;
}

.score {
  color: var(--accent);
  font-size: 40px;
  font-weight: 900;
  line-height: 1.2;
}

.lines,
.facts {
  margin: 8px 0;
  text-align: left;
}

.line,
.fact {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 4px 2px;
  border-bottom: 1px dashed rgba(200, 120, 150, 0.3);
  font-size: 14px;
}

.practice {
  margin: 6px 0 0;
  color: var(--accent);
  font-weight: 900;
}

/* Couple card */
.card-page {
  text-align: center;
}

.card-img {
  display: block;
  width: 100%;
  max-width: 420px;
  height: auto;
  margin: 8px auto;
  border-radius: 18px;
  box-shadow: 0 6px 24px rgba(70, 20, 45, 0.2);
  -webkit-touch-callout: default;
  -webkit-user-select: auto;
  user-select: auto;
}

/* Sample leaderboard */
.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 8px 0;
}

.tab {
  min-height: 44px;
  border: 2px solid var(--line);
  border-radius: 14px;
  background: #ffffff;
  color: var(--text);
  font: 800 15px/1.3 var(--font);
  cursor: pointer;
}

.tab.on {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.sample-note {
  margin: 6px 0;
  padding: 8px 10px;
  border-radius: 12px;
  background: #fff7d6;
  color: #6d4c00;
  font-size: 13px;
  font-weight: 700;
}

.rows {
  display: grid;
  gap: 8px;
  margin: 10px 0;
  padding: 0;
  list-style: none;
}

.lb-row {
  display: grid;
  grid-template-columns: 24px auto 1fr auto;
  grid-template-areas: 'rank av names score' 'rank av tag score';
  align-items: center;
  column-gap: 8px;
  padding: 8px 10px;
  border-radius: 16px;
  background: #ffffff;
  box-shadow: 0 2px 8px rgba(120, 40, 70, 0.07);
}

.lb-row.mine {
  background: #fff0f4;
  box-shadow: 0 0 0 2px var(--accent);
}

.rank {
  grid-area: rank;
  color: var(--muted);
  font-weight: 900;
  text-align: center;
}

.lb-avatars {
  grid-area: av;
  display: flex;
}

.lb-avatars canvas + canvas {
  margin-left: -8px;
}

.lb-names {
  grid-area: names;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.lb-names b {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lb-names small {
  color: var(--muted);
}

.lb-score {
  grid-area: score;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.badge.together {
  padding: 0 6px;
  border-radius: 8px;
  background: #e8f6ef;
  color: #00704f;
  font-weight: 800;
}

.tag {
  grid-area: tag;
  justify-self: start;
  padding: 0 6px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.5px;
}

.tag.sample {
  background: #fff7d6;
  color: #6d4c00;
}

.tag.practice {
  background: var(--accent);
  color: #ffffff;
}

.prizes {
  margin-top: 16px;
  font-weight: 700;
  text-align: center;
}

/* Turn the phone upright. */
.rotate {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg-top);
  color: var(--text);
  font-size: 18px;
  font-weight: 800;
  text-align: center;
}

.rotate[hidden] {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}
