:root {
  --sky: #7ecbff;
  --panel: rgba(255, 253, 244, 0.96);
  --ink: #3b2a1a;
  --accent: #ff9f1c;
  --green: #3fae4a;
  --line: #e7d7b8;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--sky);
  color: var(--ink);
  font-family: system-ui, "Segoe UI", "Arial Rounded MT Bold", sans-serif;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#game {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
}

[hidden] { display: none !important; }

#hud, #hudRight {
  position: fixed;
  top: calc(12px + env(safe-area-inset-top, 0px));
  display: flex;
  gap: 8px;
  z-index: 2;
}
#hud { left: calc(12px + env(safe-area-inset-left, 0px)); }
#hudRight { right: calc(12px + env(safe-area-inset-right, 0px)); }

.pill {
  background: var(--panel);
  border: 3px solid var(--line);
  border-radius: 999px;
  padding: 6px 16px;
  font-size: 26px;
  font-weight: 700;
  color: var(--ink);
  font-family: inherit;
}
button.pill { cursor: pointer; }
.pill.used { opacity: 0.35; }

#tapHint {
  position: fixed;
  left: 50%;
  bottom: 18%;
  transform: translateX(-50%);
  background: var(--panel);
  border-radius: 20px;
  padding: 10px 20px;
  font-size: 24px;
  font-weight: 700;
  pointer-events: none;
  animation: bob 1s ease-in-out infinite alternate;
  z-index: 2;
}
@keyframes bob { to { transform: translate(-50%, -8px); } }

.screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overflow-y: auto;
  background: rgba(40, 90, 140, 0.25);
  z-index: 3;
}

.panel {
  background: var(--panel);
  border: 4px solid var(--line);
  border-radius: 28px;
  padding: 20px 22px;
  width: min(420px, 100%);
  max-height: 100%;
  overflow-y: auto;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
  margin: auto;
}
.panel.wide { width: min(760px, 100%); }

h1 { margin: 0 0 4px; font-size: 40px; color: var(--accent); text-shadow: 2px 2px 0 #fff3c4; }
h2 { margin: 0 0 10px; font-size: 32px; }
.sub { margin: 0 0 14px; font-size: 22px; }
.stats { font-size: 24px; margin: 10px 0; }
.big-stat { font-size: 44px; margin: 4px 0; }

.preview {
  width: 220px;
  height: 160px;
  max-width: 100%;
  display: block;
  margin: 0 auto 6px;
  border-radius: 20px;
  background: linear-gradient(#bfe6ff, #e6f7d8);
}

button { font-family: inherit; }

.big {
  display: block;
  width: 100%;
  margin: 10px 0 0;
  padding: 14px 18px;
  font-size: 26px;
  font-weight: 800;
  color: #fff;
  background: var(--green);
  border: none;
  border-bottom: 5px solid #2b7f34;
  border-radius: 20px;
  cursor: pointer;
}
.big:active { transform: translateY(3px); border-bottom-width: 2px; }
.big.play { background: var(--accent); border-bottom-color: #c9720a; font-size: 32px; }
.big.alt { background: #5b8def; border-bottom-color: #3b63b8; }
.big.danger { background: #e2574c; border-bottom-color: #a8372e; }

.row { display: flex; gap: 10px; }
.row .big { flex: 1; }

.link {
  margin-top: 14px;
  background: none;
  border: none;
  font-size: 22px;
  font-weight: 700;
  color: #5b6fa8;
  cursor: pointer;
  padding: 8px;
}

.wordRow {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 8px 0;
}
.word {
  min-width: 150px;
  font-size: 30px;
  font-weight: 800;
}
.arrow {
  width: 56px;
  height: 56px;
  font-size: 26px;
  border-radius: 50%;
  border: 3px solid var(--line);
  background: #fff;
  cursor: pointer;
  color: var(--ink);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  margin: 10px 0;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  font-family: inherit;
  background: #fff;
  border: 3px solid var(--line);
  border-radius: 20px;
  padding: 8px 8px 10px;
  font-size: 19px;
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
  text-align: center;
}
.card canvas { width: 100%; height: auto; display: block; border-radius: 14px; background: linear-gradient(#bfe6ff, #e6f7d8); }
.card .name { margin-top: 6px; }
.card .small { font-size: 17px; font-weight: 600; margin-top: 2px; }
.card.on { border-color: var(--accent); box-shadow: 0 0 0 3px #ffd79a; }
.card.locked .small { color: #b0563c; }
.card .remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid var(--line);
  background: #fff;
  font-size: 16px;
  cursor: pointer;
}

.tabs { display: flex; gap: 8px; justify-content: center; }
.tab {
  flex: 1;
  max-width: 200px;
  padding: 10px;
  font-size: 22px;
  font-weight: 800;
  border-radius: 16px;
  border: 3px solid var(--line);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}
.tab.on { background: #ffe3b3; border-color: var(--accent); }

#toast {
  position: fixed;
  left: 50%;
  bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  background: var(--panel);
  border: 3px solid var(--accent);
  border-radius: 20px;
  padding: 10px 20px;
  font-size: 26px;
  font-weight: 800;
  z-index: 5;
  pointer-events: none;
  text-align: center;
}

/* Short screens (phones sideways): smaller pictures and buttons so everything fits. */
@media (max-height: 520px) {
  .panel { padding: 12px 16px; border-radius: 22px; }
  h1 { font-size: 30px; }
  h2 { font-size: 24px; margin-bottom: 6px; }
  .sub, .stats { font-size: 19px; margin: 4px 0; }
  .big-stat { font-size: 32px; }
  .preview { width: 150px; height: 100px; }
  .big { padding: 8px 14px; font-size: 21px; margin-top: 8px; border-radius: 16px; }
  .big.play { font-size: 24px; }
  .word { font-size: 22px; min-width: 120px; }
  .arrow { width: 44px; height: 44px; font-size: 20px; }
  .wordRow { margin: 4px 0; }
  .link { margin-top: 6px; font-size: 19px; padding: 4px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
  .card { font-size: 16px; }
  .card .small { font-size: 14px; }
  .tab { font-size: 18px; padding: 6px; }
  .pill { font-size: 20px; padding: 4px 12px; }
}
