:root {
  --ink: #eef2f8;
  --muted: #93a0b5;
  --line: #ffffff1f;
  --accent: #57d9a3;
  color-scheme: dark;
}

* { box-sizing: border-box; }

/* An author display rule outranks the UA's [hidden] rule, and .banner sets one. */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  overflow: hidden;
  background: #0a0c10;
  color: var(--ink);
  font: 400 15px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

#table {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: crosshair;
}

/* ---------------------------------------------------------------- top bar -- */
.bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: .9rem clamp(.7rem, 2.5vw, 1.6rem);
  pointer-events: none;
  background: linear-gradient(180deg, #05070bcc 0%, transparent 100%);
}

.title { text-align: center; flex: 1 1 auto; min-width: 0; }

h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.1rem, 3.4vw, 1.6rem);
  letter-spacing: .06em;
  text-transform: uppercase;
}

#message {
  margin: .15rem 0 0;
  min-height: 1.4em;
  color: var(--muted);
  font-size: clamp(.75rem, 2.4vw, .9rem);
}

.card {
  flex: 0 1 12.5rem;
  padding: .55rem .75rem;
  background: #10151dcc;
  border: 1px solid var(--line);
  border-radius: .7rem;
  backdrop-filter: blur(6px);
  transition: border-color .25s, box-shadow .25s, opacity .25s;
  opacity: .62;
}

.card.right { text-align: right; }

.card.active {
  opacity: 1;
  border-color: #57d9a366;
  box-shadow: 0 0 0 1px #57d9a344, 0 8px 26px -12px #57d9a3aa;
}

.card.winner { border-color: #ffd77a88; box-shadow: 0 0 24px -8px #ffd77a; opacity: 1; }

.name { display: block; font-weight: 600; }

.group {
  display: block;
  font-size: .72rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
}

.balls {
  display: flex;
  flex-wrap: wrap;
  gap: .22rem;
  margin-top: .4rem;
  min-height: 1.15rem;
}

.card.right .balls { justify-content: flex-end; }

.chip {
  display: grid;
  place-items: center;
  width: 1.15rem;
  height: 1.15rem;
  border-radius: 50%;
  background: var(--ball);
  color: #10131a;
  font-size: .6rem;
  font-weight: 700;
  box-shadow: inset 0 -2px 4px #0006, inset 0 2px 3px #fff6;
}

.chip.striped {
  background:
    linear-gradient(#f5f2ea 0 26%, var(--ball) 26% 74%, #f5f2ea 74% 100%);
}

/* ------------------------------------------------------------ power meter -- */
.power {
  position: fixed;
  right: clamp(.7rem, 2.5vw, 1.6rem);
  top: 50%;
  translate: 0 -50%;
  width: .7rem;
  height: 34vh;
  min-height: 8rem;
  padding: 3px;
  background: #0b0f16aa;
  border: 1px solid var(--line);
  border-radius: 999px;
  display: flex;
  align-items: flex-end;
  pointer-events: none;
}

#power-fill {
  display: block;
  width: 100%;
  height: 0;
  border-radius: 999px;
  background: linear-gradient(180deg, #ff6b6b, #ffd166 55%, var(--accent));
  transition: height .06s linear;
}

/* ------------------------------------------------------------------ dock -- */
.dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .5rem;
  padding: .8rem clamp(.7rem, 2.5vw, 1.6rem) clamp(.8rem, 2.5vw, 1.2rem);
  background: linear-gradient(0deg, #05070bd9 0%, transparent 100%);
  pointer-events: none;
}

#hint {
  margin: 0 0 .1rem;
  padding: .3rem .8rem;
  background: #0a0e14a8;
  border-radius: 999px;
  color: var(--muted);
  font-size: .82rem;
  text-align: center;
}

.buttons { display: flex; flex-wrap: wrap; gap: .4rem; justify-content: center; pointer-events: auto; }

button {
  padding: .45rem .9rem;
  font: inherit;
  font-size: .8rem;
  color: var(--ink);
  background: #141a24cc;
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  transition: background .2s, border-color .2s, transform .1s;
}

button:hover { background: #1d2634cc; border-color: #ffffff40; }
button:active { transform: translateY(1px); }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ------------------------------------------------------------------ help -- */
.help {
  position: fixed;
  inset: auto clamp(.7rem, 2.5vw, 1.6rem) 5.6rem;
  max-width: 34rem;
  margin-inline: auto;
  max-height: 62vh;
  overflow: auto;
  padding: 1rem 1.2rem;
  background: #0d121acc;
  border: 1px solid var(--line);
  border-radius: .9rem;
  backdrop-filter: blur(10px);
  font-size: .85rem;
}

.help h2 {
  margin: .8rem 0 .35rem;
  font-size: .72rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
}

.help h2:first-child { margin-top: 0; }
.help ul { margin: 0; padding-left: 1.1rem; }
.help li { margin: .25rem 0; color: #d6dde8; }

kbd {
  padding: .05em .35em;
  font: inherit;
  font-size: .85em;
  background: #ffffff14;
  border: 1px solid #ffffff2b;
  border-radius: .3rem;
}

/* ---------------------------------------------------------------- banner -- */
.banner {
  position: fixed;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 1rem;
  justify-items: center;
  background: #05070bb8;
  backdrop-filter: blur(3px);
  text-align: center;
  animation: fade .4s ease both;
}

.banner p {
  margin: 0;
  max-width: 22rem;
  font-family: Georgia, serif;
  font-size: clamp(1.3rem, 5vw, 2rem);
}

.banner button { padding: .6rem 1.3rem; font-size: .95rem; }

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.fallback { position: fixed; inset: 40% 1rem auto; text-align: center; }

@media (max-width: 680px) {
  .bar { flex-wrap: wrap; padding: .5rem .5rem .4rem; gap: .4rem; align-items: stretch; }
  .card { flex: 1 1 0; padding: .4rem .5rem; font-size: .78rem; }
  .name { font-size: .82rem; }
  .group { font-size: .6rem; letter-spacing: .06em; }
  .balls { min-height: .85rem; gap: .15rem; }
  .chip { width: .85rem; height: .85rem; font-size: .48rem; }
  .power { height: 22vh; width: .55rem; right: .45rem; }

  /* On a narrow screen the title is the first thing to go: the score cards and
     the message are what a player actually reads mid-frame. */
  .title { flex: 0 0 100%; order: 3; }
  h1 { display: none; }
  #message { margin: 0; font-size: .78rem; }

  .dock { padding: .5rem .5rem .7rem; gap: .35rem; }
  #hint { font-size: .74rem; padding: .25rem .6rem; }
  .buttons { gap: .3rem; }
  button { padding: .38rem .7rem; font-size: .74rem; }
  .help { inset: auto .5rem 6.4rem; max-height: 56vh; font-size: .8rem; }
}
