:root {
  --shell: #2f5d8c;
  --shell-dark: #1b3a5c;
  --lcd: #b8c99a;
  --lcd-dark: #2b3320;
  --ink: #1d2733;
  --btn: #f2b134;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  background: radial-gradient(circle at 30% 20%, #3b4a5c, #232d3a 60%, #151b23);
  font-family: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  user-select: none;
  -webkit-user-select: none;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: env(safe-area-inset-top) 12px env(safe-area-inset-bottom);
}

.device {
  width: min(380px, 100%);
  background: linear-gradient(160deg, #4a7bab, var(--shell) 55%, var(--shell-dark));
  border-radius: 48% 48% 42% 42% / 30% 30% 26% 26%;
  padding: 36px 26px 30px;
  box-shadow: inset -8px -10px 0 rgba(0,0,0,.08), inset 8px 8px 0 rgba(255,255,255,.15), 0 18px 40px rgba(0,0,0,.5);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.title {
  text-align: center;
  font-weight: 800;
  font-size: 1.3rem;
  letter-spacing: .08em;
  color: #fff;
  text-shadow: 0 2px 0 var(--shell-dark);
}

.screen-frame {
  background: #26313d;
  border-radius: 18px;
  padding: 10px;
  box-shadow: inset 0 4px 10px rgba(0,0,0,.4);
}

#screen {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 2;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: var(--lcd);
  border-radius: 6px;
}

.icons-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 22px;
  padding: 0 4px;
  color: #dfe7ef;
  font-size: .8rem;
}
.icons-row.top { margin-bottom: 6px; }
.icons-row.bottom { margin-top: 6px; justify-content: center; }
.ic { opacity: .15; transition: opacity .2s; }
.ic.on { opacity: 1; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: .2; } }

.stats {
  display: grid;
  gap: 6px;
  background: rgba(238,243,248,.9);
  border-radius: 14px;
  padding: 10px 12px;
}
.stat { display: grid; grid-template-columns: 6.5em 1fr; align-items: center; font-size: .8rem; font-weight: 600; }
.bar { height: 10px; background: rgba(0,0,0,.12); border-radius: 6px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 50%; background: #6cc070; border-radius: 6px; transition: width .4s, background .4s; }
.bar i.mid { background: #f0b43c; }
.bar i.low { background: #e5534b; }

.actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.actions button, dialog button {
  font: inherit;
  border: none;
  border-radius: 999px;
  background: var(--btn);
  box-shadow: 0 4px 0 #b9801a;
  padding: 10px 4px 8px;
  font-size: 1.4rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  cursor: pointer;
  color: var(--ink);
}
.actions button small { font-size: .7rem; font-weight: 700; }
.actions button:active, dialog button:active { transform: translateY(3px); box-shadow: 0 1px 0 #b9801a; }
.actions button:disabled { opacity: .45; }

.footer { display: flex; justify-content: space-between; align-items: center; font-size: .8rem; color: #fff; font-weight: 700; padding: 0 6px; }
.link { background: none; border: none; color: #fff; text-decoration: underline; font: inherit; cursor: pointer; }

dialog {
  border: none;
  border-radius: 22px;
  padding: 24px;
  width: min(320px, 90vw);
  text-align: center;
  background: #eef3f8;
  color: var(--ink);
  box-shadow: 0 20px 50px rgba(0,0,0,.3);
}
dialog::backdrop { background: rgba(10,15,25,.6); }
dialog h2 { margin: 0 0 8px; font-size: 1.2rem; }
dialog input {
  width: 100%;
  font: inherit;
  font-size: 1.1rem;
  padding: 10px 12px;
  border-radius: 12px;
  border: 2px solid var(--shell);
  margin: 8px 0 14px;
  text-align: center;
  user-select: text;
  -webkit-user-select: text;
}
dialog button { width: 100%; font-size: 1rem; font-weight: 800; padding: 12px; }
.game-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.game-btns button { font-size: 2rem; }
.score { font-weight: 800; font-size: 1.1rem; min-height: 1.4em; }

.pill {
  font: inherit;
  font-size: .75rem;
  font-weight: 800;
  border: none;
  border-radius: 999px;
  padding: 5px 10px;
  background: var(--btn);
  color: var(--ink);
  box-shadow: 0 2px 0 #b9801a;
  cursor: pointer;
}
.pill.off { background: rgba(255,255,255,.55); box-shadow: none; }

.version { margin: -8px 0 0; text-align: center; font-size: .65rem; color: rgba(255,255,255,.7); }

.update {
  position: fixed;
  left: 50%;
  top: calc(12px + env(safe-area-inset-top));
  transform: translateX(-50%);
  z-index: 25;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 8px 8px 14px;
  max-width: calc(100vw - 32px);
  background: #26313d;
  color: #fff;
  font-size: .85rem;
  font-weight: 700;
  border-radius: 16px;
  box-shadow: 0 6px 18px rgba(0,0,0,.3);
  white-space: nowrap;
}
.update[hidden] { display: none; }
.update button {
  font: inherit;
  border: none;
  border-radius: 999px;
  padding: 6px 12px;
  background: var(--btn);
  color: var(--ink);
  font-weight: 800;
  box-shadow: 0 3px 0 #b9801a;
  cursor: pointer;
}

.suggest { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin: -4px 0 14px; }
dialog .suggest button {
  width: auto;
  font-size: .8rem;
  font-weight: 700;
  padding: 6px 11px;
  background: #dfe8f1;
  box-shadow: 0 2px 0 #b3c3d3;
}
dialog .suggest button.dice { background: var(--btn); box-shadow: 0 2px 0 #b9801a; }
