/* Grandma's Corner - shared styles.
   Rules: big text, big buttons, strong contrast, nothing hidden,
   no hover-only states, everything fits one screen where possible. */

:root {
  --bg: #fff8ec;
  --panel: #ffffff;
  --ink: #1b1b1b;
  --ink-soft: #3d3d3d;
  --line: #2b2b2b;
  --home: #1d4e89;
  --home-ink: #ffffff;
  --focus: #ffbf00;
  --good: #1f6f3a;
  --good-bg: #e3f4e8;
  --warn-bg: #fff1c2;
  --tile-news: #dbe9ff;
  --tile-cats: #ffe0cc;
  --tile-backgammon: #f3dcc0;
  --tile-cards: #d9f2df;
  --tile-memory: #eadcff;
  --tile-more: #fff0a8;
  --radius: 22px;
  --bar-h: 108px;
  font-size: 24px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: "Noto Sans", Verdana, Tahoma, Arial, sans-serif;
  line-height: 1.35;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Visible focus for keyboard users, never removed. */
:focus-visible {
  outline: 6px solid var(--focus);
  outline-offset: 4px;
}

/* ---------- Top bar (same on every page) ---------- */
.topbar {
  flex: 0 0 auto;
  min-height: var(--bar-h);
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 12px 24px;
  background: var(--panel);
  border-bottom: 4px solid var(--line);
}

.home-btn {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  min-height: 84px;
  padding: 0 30px;
  border-radius: var(--radius);
  background: var(--home);
  color: var(--home-ink);
  font-size: 1.45rem;
  font-weight: 700;
  text-decoration: none;
  border: 4px solid #0d2a4d;
  white-space: nowrap;
}
.home-btn .icon { font-size: 2.1rem; line-height: 1; }

.page-title {
  margin: 0;
  font-size: 2.1rem;
  font-weight: 700;
  flex: 1 1 auto;
}

.today {
  font-size: 1.15rem;
  color: var(--ink-soft);
  text-align: right;
  white-space: nowrap;
}

.sound-btn { min-height: 72px; padding: 0 18px; font-size: 1.05rem; white-space: nowrap; }
.home-sound { position: absolute; top: 14px; right: 18px; }
/* Narrower screens: the date goes and the sound switch keeps just its icon. */
@media (max-width: 1400px) {
  .topbar .today { display: none; }
}
@media (max-width: 760px) {
  .topbar .sound-btn span:last-child { display: none; }
  .topbar .sound-btn { padding: 0 12px; }
}

/* ---------- Main area ---------- */
main {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  padding: 20px 24px 24px;
  gap: 20px;
  min-height: 0;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 84px;
  min-width: 84px;
  padding: 0 30px;
  border-radius: var(--radius);
  border: 4px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  font-size: 1.3rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}
.btn .icon { font-size: 1.8rem; line-height: 1; }
.btn:active { transform: translateY(2px); }
.btn.primary { background: var(--home); color: #fff; border-color: #0d2a4d; }
.btn.go { background: var(--good); color: #fff; border-color: #0f3d1f; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  justify-content: center;
}

/* ---------- Message strip: says in words what to do ---------- */
.message {
  margin: 0;
  padding: 14px 22px;
  border-radius: var(--radius);
  border: 3px solid var(--line);
  background: var(--warn-bg);
  font-size: 1.35rem;
  font-weight: 700;
  text-align: center;
}
.message.good { background: var(--good-bg); }

/* ---------- Home tiles ---------- */
.greeting {
  margin: 0;
  text-align: center;
  font-size: 2.2rem;
}
.greeting small {
  display: block;
  font-size: 1.3rem;
  font-weight: 400;
  color: var(--ink-soft);
}

.tiles {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-auto-rows: 1fr;
  gap: 24px;
  min-height: 0;
}

.tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px;
  min-height: 170px;
  border-radius: 28px;
  border: 5px solid var(--line);
  color: var(--ink);
  text-decoration: none;
  text-align: center;
}
.tile .icon { font-size: clamp(3rem, 9vh, 6.5rem); line-height: 1; }
.tile .label { font-size: clamp(1.2rem, min(4.6vh, 6.4vw), 2.6rem); font-weight: 700; overflow-wrap: anywhere; }
.tile .hint { font-size: 1.05rem; color: var(--ink-soft); }
.tile:active { transform: translateY(3px); }

.tile.news { background: var(--tile-news); }
.tile.cats { background: var(--tile-cats); }
.tile.backgammon { background: var(--tile-backgammon); }
.tile.cards { background: var(--tile-cards); }
.tile.memory { background: var(--tile-memory); }
.tile.more { background: var(--tile-more); }
.tile.radio { background: #ffd9d9; }
.tile.tv { background: #d6eef5; }
.tile.fund { background: #efe2c8; }
.tile.flowers { background: #fde2f1; }
.tile.russian { background: #e2e6ff; }
.tile.french { background: #dff3f0; }

/* Home with twelve tiles: four across, three down, all on one screen. */
.home-tiles { grid-template-columns: repeat(4, 1fr); gap: 18px; }
.home-tiles .tile { min-height: 0; padding: 8px; gap: 4px; }
.home-tiles .tile .icon { font-size: clamp(2.2rem, 7vh, 4.6rem); }
.home-tiles .tile .label { font-size: clamp(1.15rem, min(3.8vh, 3vw), 2.1rem); }
.home-tiles .tile .hint { font-size: 0.95rem; }
@media (max-width: 900px) { .home-tiles { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 520px) { .home-tiles { grid-template-columns: repeat(2, 1fr); } }
@media (max-height: 560px) and (min-width: 521px) { .home-tiles { grid-template-columns: repeat(4, 1fr); gap: 10px; } }

/* ---------- "How to play" full-screen panel ---------- */
.help {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  flex-direction: column;
  gap: 24px;
  padding: 32px 48px;
  background: var(--bg);
  overflow: auto;
}
.help.open { display: flex; }
.help h2 { margin: 0; font-size: 2.2rem; }
.help ol { margin: 0; padding-left: 1.4em; font-size: 1.4rem; }
.help li { margin-bottom: 14px; }

/* ---------- Page that might need scrolling: say so loudly ---------- */
.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  font-size: 1.3rem;
  font-weight: 700;
}

/* Narrow screens (phones, small tablets) */
@media (max-width: 900px) {
  :root { font-size: 20px; }
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .today { display: none; }
  .topbar { padding: 10px 14px; gap: 14px; }
  .home-btn { padding: 0 18px; }
  main { padding: 14px 16px 18px; }
}
@media (max-width: 520px) {
  :root { font-size: 18px; }
  .tiles { grid-template-columns: repeat(2, 1fr); gap: 14px; }
  .tile { min-height: 0; padding: 10px; border-width: 4px; }
  .tile .hint { display: none; }
  .page-title { font-size: 1.35rem; overflow-wrap: anywhere; }
  .home-btn { min-height: 72px; padding: 0 14px; font-size: 1.2rem; }
  .btn { padding: 0 16px; }
  .pager { gap: 10px; }
  .pager .btn .icon { display: none; }
  .greeting { font-size: 1.8rem; }
}

/* Short screens: a small laptop, or any screen with the browser zoomed in. */
@media (max-height: 560px) {
  :root { font-size: 17px; --bar-h: 64px; }
  .topbar { padding: 6px 14px; border-bottom-width: 3px; }
  .home-btn { min-height: 52px; padding: 0 16px; border-width: 3px; }
  .home-btn .icon { font-size: 1.5rem; }
  .page-title { font-size: 1.5rem; }
  .today { display: none; }
  .sound-btn { min-height: 48px !important; }
  main { padding: 8px 14px 10px; gap: 8px !important; }
  .message { padding: 6px 14px; font-size: 1.05rem; }
  .btn, .controls .btn { min-height: 52px !important; padding: 0 14px !important; font-size: 0.95rem !important; border-width: 3px; }
  .btn .icon { font-size: 1.3rem; }
  .btn-row, .controls { gap: 8px !important; }
  .greeting { font-size: 1.5rem; }
  .greeting small { display: inline; margin-left: 0.6em; font-size: 1rem; }
  .tiles { grid-template-columns: repeat(3, 1fr); gap: 12px; }
  .tile { min-height: 0; padding: 6px; border-width: 4px; gap: 2px; }
  .tile .hint { display: none; }
  .help { padding: 12px 20px; gap: 10px; }
  .help h2 { font-size: 1.5rem; }
  .help ol { font-size: 1.1rem; }
  .help li { margin-bottom: 6px; }
}

/* Game pages: the playing area and its buttons. On short, wide screens the
   buttons move into a column at the side so the game itself stays big. */
.game-wrap {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
@media (max-height: 560px) and (orientation: landscape) {
  .game-wrap { flex-direction: row; gap: 10px; }
  .game-wrap > .controls {
    flex: 0 0 auto;
    width: 210px;
    flex-direction: column;
    flex-wrap: nowrap;
    justify-content: center;
  }
  .game-wrap > .controls .btn { width: 100%; }
}

/* Picture pages (cats, flowers). */
.hidden { display: none !important; }
.cat-frame {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 5px solid var(--line);
  border-radius: 28px;
  background: #f2e6d3;
  overflow: hidden;
}
.cat-frame img { width: 100%; height: 100%; object-fit: contain; }
.cat-frame .message { margin: 24px; }
.credit { margin: -6px 0 0; text-align: center; font-size: 0.85rem; color: var(--ink-soft); min-height: 1.2em; }
.pic-controls { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; }
.pic-controls .btn { min-height: 84px; font-size: 1.2rem; padding: 0 26px; }
.btn.love { background: #ffe0e6; border-color: #a3123a; color: #6d0b27; }
.btn.love[disabled] { opacity: 1; background: var(--good-bg); border-color: var(--good); color: var(--good); }
.btn.danger { border-color: #a3123a; color: #a3123a; }
.btn.danger.sure { background: #a3123a; color: #fff; }
@media (max-height: 560px) {
  .pic-controls .btn { min-height: 52px; font-size: 0.95rem; padding: 0 14px; }
}

/* The "there is more below" bar, shown only when a page has to scroll. */
.more-below {
  position: fixed;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  z-index: 40;
  display: none;
  align-items: center;
  gap: 12px;
  padding: 10px 26px;
  border-radius: 999px;
  border: 4px solid #0d2a4d;
  background: var(--home);
  color: #fff;
  font: inherit;
  font-size: 1.15rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}
.more-below.show { display: inline-flex; }
.more-below .icon { font-size: 1.6rem; animation: nudge 1.2s ease-in-out infinite; }
@keyframes nudge { 50% { transform: translateY(5px); } }

/* People who asked their computer for less motion */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
