:root {
  --ink: #24304a;
  --muted: #65708a;
  --white: #ffffff;
  --aqua: #55d6d2;
  --aqua-dark: #168f91;
  --mint: #74d58b;
  --yellow: #ffd84d;
  --orange: #ff8a4c;
  --pink: #ff6f91;
  --blue: #5595f5;
  --purple: #a576e8;
  --red: #e64164;
  font-family: "Trebuchet MS", "Arial Rounded MT Bold", ui-sans-serif, system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-height: 100%;
  background: #76dcd8;
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  letter-spacing: 0;
  overscroll-behavior: contain;
  background-color: #76dcd8;
  background-image: url("./assets/playroom-bg.webp");
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
  background-attachment: fixed;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
summary:focus-visible,
.brand:focus-visible,
.player-zone:focus-visible {
  outline: 4px solid var(--yellow);
  outline-offset: 3px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.46;
}

.game-shell {
  width: min(1260px, calc(100% - 18px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 10px 0 24px;
}

.game-header {
  position: relative;
  z-index: 20;
  display: flex;
  min-height: 66px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 6px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
}

.brand-butterfly {
  display: grid;
  width: 52px;
  height: 52px;
  place-items: center;
  border: 3px solid #e4aa1a;
  border-radius: 50%;
  background: var(--yellow);
  box-shadow: 0 5px 0 #c98418;
  font-size: 1.95rem;
  transform: rotate(-8deg);
  transition: transform 150ms ease;
}

.brand:hover .brand-butterfly {
  transform: rotate(4deg) scale(1.05);
}

.brand p,
.brand h1,
.stage p,
.stage h2,
.setup-title p,
.setup-title h2 {
  margin: 0;
}

.brand p {
  color: #148075;
  font-size: 0.7rem;
  font-weight: 950;
  text-transform: uppercase;
}

.brand h1 {
  color: #283454;
  font-size: clamp(1.45rem, 3.6vw, 2.8rem);
  line-height: 0.98;
  text-shadow: 0 3px 0 white;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 9px;
}

.touch-meter {
  max-width: 290px;
  color: #4a6570;
  font-size: 0.76rem;
  font-weight: 850;
  text-align: right;
}

.round-button,
.step-button,
.dialog-close {
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  color: var(--ink);
  font-weight: 950;
}

.round-button {
  width: 44px;
  height: 44px;
  border: 3px solid rgba(36, 48, 74, 0.14);
  background: white;
  box-shadow: 0 4px 0 rgba(36, 48, 74, 0.2);
  font-size: 1.45rem;
}

.settings-button {
  background: var(--yellow);
}

.mic-button {
  background: #ffddeb;
  color: #93405f;
}

.mic-button.is-on {
  background: var(--mint);
  color: #185d3a;
}

.mic-button.is-connected {
  border-color: #167c54;
  background: #59de8d;
  box-shadow:
    0 4px 0 #2a9d61,
    0 0 0 5px rgba(89, 222, 141, 0.28);
}

.mic-button.has-error {
  background: #ff6680;
  color: white;
}

.round-button:active,
.step-button:active,
.dialog-close:active,
.start-button:active {
  box-shadow: none;
  transform: translateY(4px);
}

.table-scene {
  position: relative;
  display: grid;
  min-height: calc(100svh - 110px);
  place-items: center;
  overflow: hidden;
  padding: clamp(72px, 9vw, 118px);
}

.round-table {
  position: relative;
  isolation: isolate;
  width: min(67vw, 720px);
  aspect-ratio: 1;
  border: clamp(13px, 1.8vw, 20px) solid #e99a3e;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 44%, rgba(255, 255, 255, 0.23), transparent 52%),
    #43bb78;
  box-shadow:
    0 0 0 7px #954e2a,
    0 18px 0 7px #69381f,
    0 32px 45px rgba(47, 76, 81, 0.35);
}

.round-table::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 2.2%;
  border: 3px dashed rgba(255, 255, 255, 0.28);
  border-radius: 50%;
  pointer-events: none;
}

.round-table::after {
  content: "";
  position: absolute;
  z-index: -2;
  inset: -6%;
  border: 2px solid rgba(255, 255, 255, 0.72);
  border-radius: 50%;
  pointer-events: none;
}

.table-mark {
  position: absolute;
  z-index: -1;
  width: 14px;
  height: 14px;
  border: 3px solid rgba(255, 255, 255, 0.58);
  border-radius: 50%;
}

.table-mark-one {
  top: 20%;
  left: 18%;
}

.table-mark-two {
  right: 18%;
  bottom: 20%;
  width: 9px;
  height: 9px;
}

.player-ring {
  position: absolute;
  z-index: 5;
  inset: 0;
  border-radius: 50%;
  pointer-events: none;
}

.player-zone {
  --player-color: var(--blue);
  position: absolute;
  width: clamp(90px, 11vw, 132px);
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  border-radius: 50%;
  pointer-events: auto;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  transform: translate(-50%, -50%);
}

.zone-surface {
  position: relative;
  display: grid;
  width: 100%;
  height: 100%;
  grid-template-rows: 1fr auto;
  place-items: center;
  gap: 1px;
  overflow: hidden;
  padding: 10%;
  border: clamp(3px, 0.45vw, 5px) solid white;
  border-radius: 50%;
  background: var(--player-color);
  box-shadow:
    0 7px 0 color-mix(in srgb, var(--player-color) 55%, #493040),
    0 11px 18px rgba(36, 48, 74, 0.24);
  transition: transform 120ms ease, filter 120ms ease;
}

.zone-surface::before {
  content: "";
  position: absolute;
  top: -32%;
  left: -20%;
  width: 92%;
  height: 68%;
  border: 10px solid rgba(255, 255, 255, 0.22);
  border-radius: 50%;
  transform: rotate(-18deg);
}

.zone-meta {
  position: absolute;
  z-index: 4;
  bottom: calc(100% + 9px);
  left: 50%;
  display: grid;
  min-width: clamp(104px, 10vw, 132px);
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "name lives"
    "score score";
  align-items: center;
  gap: 2px 7px;
  padding: 7px 9px;
  border: 2px solid color-mix(in srgb, var(--player-color) 72%, #34405b);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow:
    0 4px 0 color-mix(in srgb, var(--player-color) 42%, #5b4460),
    0 7px 14px rgba(36, 48, 74, 0.18);
  pointer-events: none;
  transform: translateX(-50%);
}

.player-zone[data-meta-side="bottom"] .zone-meta {
  top: calc(100% + 13px);
  bottom: auto;
}

.player-name {
  grid-area: name;
  overflow: hidden;
  font-size: clamp(0.72rem, 1.15vw, 0.9rem);
  font-weight: 950;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lives {
  grid-area: lives;
  color: #9d1839;
  font-family: Arial, sans-serif;
  font-size: clamp(0.78rem, 1.15vw, 0.96rem);
  font-weight: 950;
  letter-spacing: 0;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.72);
  white-space: nowrap;
}

.finger-target {
  position: relative;
  z-index: 1;
  display: grid;
  min-height: 0;
  place-items: center;
}

.finger-target::before,
.finger-target::after {
  content: "";
  position: absolute;
  width: clamp(35px, 4vw, 52px);
  aspect-ratio: 1;
  border: 3px solid rgba(255, 255, 255, 0.5);
  border-radius: 50%;
}

.finger-target::after {
  width: clamp(46px, 5.3vw, 67px);
  border-width: 2px;
  opacity: 0.55;
}

.finger-icon {
  position: relative;
  z-index: 1;
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
  font-size: clamp(2rem, 4.2vw, 3.2rem);
  line-height: 1;
  filter: drop-shadow(0 3px 0 rgba(36, 48, 74, 0.16));
  transform: rotate(-7deg);
  transition: transform 120ms ease;
}

.zone-status {
  position: relative;
  z-index: 2;
  width: 88%;
  overflow: hidden;
  font-size: clamp(0.56rem, 0.86vw, 0.72rem);
  font-weight: 950;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.score {
  grid-area: score;
  color: #73541a;
  font-size: clamp(0.66rem, 0.9vw, 0.78rem);
  font-weight: 950;
}

.touch-dot {
  position: absolute;
  z-index: 2;
  right: 13%;
  bottom: 12%;
  width: 10px;
  height: 10px;
  border: 2px solid white;
  border-radius: 50%;
  background: rgba(36, 48, 74, 0.34);
}

.player-zone.is-down .zone-surface {
  filter: saturate(1.2);
  transform: translateY(6px) scale(0.94);
  box-shadow:
    0 1px 0 color-mix(in srgb, var(--player-color) 55%, #493040),
    0 4px 8px rgba(36, 48, 74, 0.2);
}

.player-zone.is-down .finger-icon {
  transform: translateY(4px) rotate(-7deg) scale(0.9);
}

.player-zone.is-down .finger-target::before {
  animation: touch-pulse 800ms ease-out infinite;
}

.player-zone.is-down .touch-dot {
  background: white;
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.25);
}

.player-zone.is-correct .zone-surface {
  border-color: #edffb9;
  background: #64df91;
  animation: correct-pop 450ms ease;
}

.player-zone.is-burned .zone-surface {
  border-color: #ffe5eb;
  background: #ff5f79;
  animation: burned-shake 430ms ease;
}

.player-zone.is-burned .finger-icon::after {
  content: "\1F525";
  position: absolute;
  top: -16px;
  right: -19px;
  font-size: 1.55rem;
}

.player-zone.is-out {
  opacity: 0.42;
  filter: grayscale(0.75);
}

.player-zone.is-remote {
  cursor: default;
  pointer-events: none;
}

.player-zone.is-remote .zone-surface {
  box-shadow:
    0 7px 0 color-mix(in srgb, var(--player-color) 55%, #493040),
    0 0 0 5px rgba(255, 255, 255, 0.28),
    0 11px 18px rgba(36, 48, 74, 0.24);
}

.stage {
  --stage-border-size: clamp(5px, 0.8vw, 9px);
  --stage-timer-angle: 0deg;
  position: absolute;
  z-index: 3;
  inset: 19%;
  display: flex;
  min-width: 0;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(4px, 0.7vw, 9px);
  padding: clamp(12px, 2vw, 25px);
  border: var(--stage-border-size) solid #dce8e5;
  border-radius: 50%;
  background: #f8fff2;
  box-shadow:
    0 0 0 6px rgba(255, 255, 255, 0.64),
    0 12px 0 rgba(20, 111, 77, 0.24);
  text-align: center;
}

.stage-timer-progress {
  position: absolute;
  z-index: 2;
  inset: calc(-1 * var(--stage-border-size));
  padding: var(--stage-border-size);
  border-radius: 50%;
  background: conic-gradient(
    from -90deg,
    #ffd84d var(--stage-timer-angle),
    #dce8e5 0deg
  );
  pointer-events: none;
  transform: scaleX(-1);
  -webkit-mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  mask-composite: exclude;
}

.round-row {
  position: absolute;
  top: 5.5%;
  display: flex;
  width: 78%;
  justify-content: space-between;
  gap: 8px;
}

.round-badge,
.alive-badge {
  padding: 5px 9px;
  border: 2px solid rgba(36, 48, 74, 0.12);
  border-radius: 999px;
  background: white;
  box-shadow: 0 3px 0 rgba(36, 48, 74, 0.12);
  font-size: clamp(0.58rem, 0.9vw, 0.75rem);
  font-weight: 950;
}

.alive-badge {
  background: #dff8ff;
}

.chant {
  margin-top: 7% !important;
  color: #12807b;
  font-size: clamp(0.62rem, 1.2vw, 0.92rem);
  font-weight: 950;
}

.item-display {
  position: relative;
  display: grid;
  width: min(40%, 178px);
  min-width: 112px;
  aspect-ratio: 1.1;
  place-items: center;
}

.item-shadow {
  position: absolute;
  bottom: 3%;
  width: 62%;
  height: 12%;
  border-radius: 50%;
  background: rgba(36, 48, 74, 0.17);
  filter: blur(3px);
}

.item-icon {
  position: relative;
  z-index: 1;
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
  font-size: clamp(4.8rem, 10vw, 8.2rem);
  line-height: 1;
  filter: drop-shadow(0 8px 1px rgba(36, 48, 74, 0.12));
  transform-origin: 50% 100%;
}

.timer-ring {
  --timer-angle: 0deg;
  position: absolute;
  z-index: 3;
  top: -4%;
  right: -22%;
  display: grid;
  width: clamp(58px, 6.2vw, 78px);
  aspect-ratio: 1;
  place-items: center;
  border: 4px solid white;
  border-radius: 50%;
  background: white;
  box-shadow:
    0 0 0 5px var(--yellow),
    0 5px 0 rgba(36, 48, 74, 0.16);
  isolation: isolate;
  pointer-events: none;
}

.timer-ring::before {
  content: "";
  position: absolute;
  z-index: 0;
  inset: 0;
  border-radius: 50%;
  background:
    radial-gradient(circle at center, white 55%, transparent 57%),
    conic-gradient(
      from -90deg,
      var(--orange) var(--timer-angle),
      rgba(36, 48, 74, 0.16) 0deg
    );
  transform: scaleX(-1);
}

.timer-ring span {
  position: relative;
  z-index: 1;
  grid-area: 1 / 1;
  transform: translateY(-4px);
  font-size: clamp(0.92rem, 1.5vw, 1.25rem);
  font-weight: 950;
}

.timer-ring small {
  position: relative;
  z-index: 1;
  grid-area: 1 / 1;
  transform: translateY(12px);
  color: var(--muted);
  font-size: 0.55rem;
  font-weight: 900;
}

.stage h2 {
  max-width: 94%;
  font-size: clamp(1.1rem, 2.8vw, 2.35rem);
  line-height: 1.02;
  text-wrap: balance;
}

.rule-text {
  max-width: 85%;
  color: #50647a;
  font-size: clamp(0.64rem, 1.1vw, 0.86rem);
  font-weight: 850;
  text-wrap: balance;
}

.verdict {
  max-width: 82%;
  padding: 5px 9px;
  border: 2px solid rgba(36, 48, 74, 0.12);
  border-radius: 999px;
  background: #dff8ff;
  font-size: clamp(0.6rem, 0.95vw, 0.78rem);
  font-weight: 950;
}

.play-again {
  min-height: 42px;
  padding: 0 16px;
  border: 3px solid #d9572f;
  border-radius: 8px;
  background: var(--orange);
  box-shadow: 0 5px 0 #b53d1f;
  color: white;
  font-size: 0.82rem;
  font-weight: 950;
  text-shadow: 0 2px 0 rgba(111, 33, 11, 0.3);
}

.play-again span {
  margin-right: 5px;
  font-size: 1.1rem;
}

.play-again:active {
  box-shadow: none;
  transform: translateY(4px);
}

.settings-dialog {
  width: min(440px, calc(100% - 24px));
  max-height: calc(100dvh - 24px);
  overflow: visible;
  padding: 0;
  border: 0;
  background: transparent;
}

.settings-dialog::backdrop {
  background: rgba(36, 48, 74, 0.62);
  backdrop-filter: blur(5px);
}

.settings-dialog[open] {
  animation: dialog-in 220ms ease-out;
}

.settings-panel {
  position: relative;
  display: grid;
  gap: 16px;
  padding: 24px;
  border: 7px solid var(--yellow);
  border-radius: 24px;
  background:
    linear-gradient(135deg, rgba(85, 214, 210, 0.12), rgba(255, 111, 145, 0.1)),
    white;
  box-shadow:
    0 9px 0 #d99d20,
    0 24px 45px rgba(23, 35, 61, 0.34);
}

.dialog-close {
  position: absolute;
  z-index: 2;
  top: -17px;
  right: -17px;
  width: 42px;
  height: 42px;
  border: 3px solid white;
  background: var(--pink);
  box-shadow: 0 4px 0 #bd3558;
  color: white;
  font-size: 1.5rem;
}

.setup-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.setup-title > span {
  display: grid;
  width: 64px;
  height: 64px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  background: #dff8ff;
  font-size: 2.6rem;
}

.setup-title p {
  color: #148075;
  font-size: 0.67rem;
  font-weight: 950;
}

.setup-title h2 {
  font-size: 1.55rem;
  line-height: 1;
}

.setup-title small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 750;
}

.mode-picker {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
}

.mode-button {
  display: grid;
  min-width: 0;
  min-height: 68px;
  place-items: center;
  gap: 3px;
  padding: 7px 4px;
  border: 2px solid rgba(36, 48, 74, 0.1);
  border-radius: 8px;
  background: #f4f8ff;
  color: #536078;
  font-size: 0.68rem;
  font-weight: 950;
}

.mode-button span {
  font-size: 1.55rem;
}

.mode-button.is-selected {
  border-color: #df9d23;
  background: var(--yellow);
  box-shadow: inset 0 -4px 0 rgba(183, 119, 12, 0.16);
  color: var(--ink);
}

.preference-panel {
  display: grid;
  min-width: 0;
  grid-template-columns: repeat(var(--preference-count, 3), minmax(0, 1fr));
  gap: 7px;
  margin: 0;
  padding: 12px 10px 10px;
  border: 2px solid rgba(36, 48, 74, 0.1);
  border-radius: 8px;
  background: #fff8fc;
}

.preference-panel legend {
  padding: 0 6px;
  color: #7b5268;
  font-size: 0.68rem;
  font-weight: 950;
  text-transform: uppercase;
}

.preference-toggle {
  position: relative;
  display: grid;
  min-width: 0;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 3px 5px;
  color: #536078;
  cursor: pointer;
  font-size: 0.67rem;
  font-weight: 950;
}

.preference-icon {
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
  font-size: 1rem;
}

.preference-toggle input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.toggle-track {
  position: relative;
  display: block;
  width: 40px;
  height: 23px;
  grid-column: 1 / -1;
  margin: 3px auto 0;
  border: 2px solid rgba(36, 48, 74, 0.16);
  border-radius: 999px;
  background: #dfe5ed;
  transition: background 140ms ease;
}

.toggle-track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 2px 4px rgba(36, 48, 74, 0.22);
  transition: transform 140ms ease;
}

.preference-toggle input:checked + .toggle-track {
  border-color: #1f9e73;
  background: var(--mint);
}

.preference-toggle input:checked + .toggle-track::after {
  transform: translateX(17px);
}

.preference-toggle input:focus-visible + .toggle-track {
  outline: 4px solid var(--yellow);
  outline-offset: 2px;
}

.setting-row {
  display: flex;
  min-height: 64px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 2px solid rgba(36, 48, 74, 0.1);
  border-radius: 8px;
  background: #f7fbff;
}

.online-panel {
  display: grid;
  gap: 10px;
  padding: 11px;
  border: 2px solid rgba(36, 48, 74, 0.1);
  border-radius: 8px;
  background: #ebfbfa;
}

.online-panel[hidden],
.share-box[hidden] {
  display: none;
}

.room-button,
.share-line button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  background: var(--aqua-dark);
  color: white;
  font-weight: 950;
}

.share-box {
  display: grid;
  gap: 5px;
}

.share-box label {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 900;
  text-transform: uppercase;
}

.share-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
}

.share-line input {
  min-width: 0;
  height: 42px;
  border: 2px solid rgba(36, 48, 74, 0.15);
  border-radius: 8px;
  background: white;
  color: #46536a;
  font-size: 0.72rem;
  font-weight: 750;
}

.share-line button {
  padding: 0 13px;
  background: var(--blue);
}

.online-status {
  margin: 0;
  color: #3b5a68;
  font-size: 0.72rem;
  font-weight: 850;
  text-align: center;
}

.voice-status {
  margin: 0;
  padding-top: 8px;
  border-top: 1px dashed rgba(36, 48, 74, 0.16);
  color: #79536a;
  font-size: 0.7rem;
  font-weight: 900;
  text-align: center;
}

.control-label {
  color: #4f5c73;
  font-size: 0.78rem;
  font-weight: 950;
  text-transform: uppercase;
}

.control-group,
.range-line {
  display: flex;
  align-items: center;
  gap: 9px;
}

.step-button {
  width: 42px;
  height: 42px;
  background: #dcecff;
  box-shadow: 0 4px 0 #adc7e6;
  font-size: 1.35rem;
}

.step-button:last-child {
  background: #ffddeb;
  box-shadow: 0 4px 0 #e6a7be;
}

.player-output {
  min-width: 28px;
  font-size: 1.5rem;
  font-weight: 950;
  text-align: center;
}

.range-line input {
  width: 155px;
  accent-color: var(--orange);
}

#timeOutput {
  min-width: 28px;
  font-weight: 950;
  text-align: right;
}

.seconds-label {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 850;
}

.start-button {
  min-height: 54px;
  border: 3px solid #d9572f;
  border-radius: 8px;
  background: var(--orange);
  box-shadow: 0 6px 0 #b53d1f;
  color: white;
  font-weight: 950;
  text-shadow: 0 2px 0 rgba(111, 33, 11, 0.3);
}

.start-button span:first-child {
  margin-right: 6px;
}

.round-log {
  width: min(560px, 100%);
  margin: 4px auto 0;
  color: #4a6570;
  font-size: 0.78rem;
  font-weight: 850;
}

.round-log summary {
  width: max-content;
  margin: 0 auto;
  cursor: pointer;
}

.round-log ol {
  display: grid;
  gap: 6px;
  margin: 9px 0 0;
  padding: 11px 11px 11px 32px;
  border: 2px solid rgba(36, 48, 74, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
}

body[data-phase="active"] .item-icon {
  animation: item-reveal 420ms cubic-bezier(0.2, 0.9, 0.3, 1.25);
}

body[data-phase="arming"] .item-icon {
  animation: ready-bob 650ms ease-in-out infinite alternate;
}

body[data-phase="results"] .verdict {
  animation: verdict-pop 430ms ease;
}

body[data-phase="gameover"] .item-icon {
  animation: winner-bounce 800ms ease-in-out infinite alternate;
}

@keyframes dialog-in {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.94);
  }
}

@keyframes touch-pulse {
  from {
    opacity: 0.95;
    transform: scale(0.7);
  }
  to {
    opacity: 0;
    transform: scale(1.38);
  }
}

@keyframes item-reveal {
  0% {
    opacity: 0;
    transform: translateY(34px) scale(0.55) rotate(-10deg);
  }
  75% {
    transform: translateY(-7px) scale(1.07) rotate(4deg);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1) rotate(0);
  }
}

@keyframes ready-bob {
  to {
    transform: translateY(-10px) rotate(5deg);
  }
}

@keyframes correct-pop {
  50% {
    transform: scale(1.1);
  }
}

@keyframes burned-shake {
  20%,
  60% {
    transform: translateX(-5px) rotate(-3deg);
  }
  40%,
  80% {
    transform: translateX(5px) rotate(3deg);
  }
}

@keyframes verdict-pop {
  50% {
    transform: scale(1.08);
  }
}

@keyframes winner-bounce {
  to {
    transform: translateY(-10px) rotate(7deg);
  }
}

@media (max-width: 700px) {
  body {
    background-attachment: scroll;
    background-position: center top;
  }

  .game-shell {
    width: min(100% - 10px, 1260px);
    padding-top: 6px;
  }

  .game-header {
    min-height: 54px;
    padding: 0 3px;
  }

  .brand {
    gap: 7px;
  }

  .brand-butterfly {
    width: 41px;
    height: 41px;
    border-width: 2px;
    box-shadow: 0 4px 0 #c98418;
    font-size: 1.55rem;
  }

  .brand p,
  .touch-meter {
    display: none;
  }

  .brand h1 {
    max-width: 190px;
    font-size: clamp(1.12rem, 5.3vw, 1.5rem);
  }

  .header-actions {
    gap: 6px;
  }

  .round-button {
    width: 39px;
    height: 39px;
    border-width: 2px;
    font-size: 1.2rem;
  }

  .table-scene {
    min-height: calc(100svh - 76px);
    overflow: visible;
    padding: 56px 0 66px;
  }

  .round-table {
    width: clamp(248px, calc(100vw - 104px), 430px);
    border-width: 12px;
    box-shadow:
      0 0 0 5px #954e2a,
      0 11px 0 5px #69381f,
      0 20px 30px rgba(47, 76, 81, 0.32);
  }

  .player-zone {
    width: clamp(76px, 20vw, 102px);
  }

  body[data-players="7"] .player-zone,
  body[data-players="8"] .player-zone {
    width: clamp(70px, 18vw, 88px);
  }

  .zone-surface {
    padding: 7%;
    border-width: 3px;
    box-shadow:
      0 5px 0 color-mix(in srgb, var(--player-color) 55%, #493040),
      0 8px 12px rgba(36, 48, 74, 0.22);
  }

  .zone-meta {
    min-width: 88px;
    gap: 1px 5px;
    padding: 5px 7px;
    box-shadow:
      0 3px 0 color-mix(in srgb, var(--player-color) 42%, #5b4460),
      0 5px 10px rgba(36, 48, 74, 0.16);
  }

  .player-name {
    font-size: 0.68rem;
  }

  .lives {
    font-size: 0.72rem;
  }

  .finger-icon {
    font-size: clamp(1.75rem, 8vw, 2.4rem);
  }

  .finger-target::before {
    width: 31px;
  }

  .finger-target::after {
    width: 41px;
  }

  .zone-status {
    font-size: 0.48rem;
  }

  .score {
    font-size: 0.61rem;
  }

  .touch-dot {
    width: 8px;
    height: 8px;
    border-width: 1px;
  }

  body[data-players="7"] .zone-meta,
  body[data-players="8"] .zone-meta {
    min-width: 78px;
    padding-inline: 5px;
  }

  body[data-players="7"] .player-name,
  body[data-players="8"] .player-name {
    font-size: 0.58rem;
  }

  body[data-players="7"] .lives,
  body[data-players="8"] .lives {
    font-size: 0.62rem;
  }

  body[data-players="7"] .score,
  body[data-players="8"] .score {
    font-size: 0.54rem;
  }

  .stage {
    --stage-border-size: 5px;
    inset: 18%;
    gap: 2px;
    padding: 8px;
    box-shadow:
      0 0 0 4px rgba(255, 255, 255, 0.64),
      0 7px 0 rgba(20, 111, 77, 0.24);
  }

  .round-row {
    top: 5%;
    width: 82%;
  }

  .round-badge,
  .alive-badge {
    padding: 3px 5px;
    border-width: 1px;
    box-shadow: 0 2px 0 rgba(36, 48, 74, 0.1);
    font-size: 0.48rem;
  }

  .chant {
    margin-top: 12% !important;
    font-size: 0.48rem;
  }

  .item-display {
    width: 52%;
    min-width: 72px;
  }

  .item-icon {
    font-size: clamp(3.25rem, 16vw, 4.5rem);
    filter: drop-shadow(0 4px 1px rgba(36, 48, 74, 0.12));
  }

  .timer-ring {
    top: -8%;
    right: -28%;
    width: 44px;
    border-width: 3px;
    box-shadow:
      0 0 0 4px var(--yellow),
      0 3px 0 rgba(36, 48, 74, 0.14);
  }

  .timer-ring span {
    font-size: 0.76rem;
  }

  .timer-ring small {
    transform: translateY(9px);
    font-size: 0.43rem;
  }

  .stage h2 {
    max-width: 96%;
    font-size: clamp(0.78rem, 4vw, 1.08rem);
  }

  .rule-text {
    display: none;
  }

  .verdict {
    max-width: 90%;
    padding: 2px 5px;
    border-width: 1px;
    font-size: 0.48rem;
  }

  .play-again {
    min-height: 30px;
    padding: 0 9px;
    border-width: 2px;
    box-shadow: 0 3px 0 #b53d1f;
    font-size: 0.58rem;
  }

  .play-again span {
    font-size: 0.76rem;
  }

  .round-log {
    margin-top: 0;
    font-size: 0.7rem;
  }
}

@media (max-width: 430px) {
  .settings-panel {
    gap: 13px;
    padding: 20px 15px;
    border-width: 6px;
  }

  .setup-title > span {
    width: 52px;
    height: 52px;
    font-size: 2rem;
  }

  .setup-title h2 {
    font-size: 1.28rem;
  }

  .mode-button {
    min-height: 60px;
    font-size: 0.59rem;
  }

  .mode-button span {
    font-size: 1.25rem;
  }

  .preference-panel {
    padding-inline: 7px;
  }

  .preference-toggle {
    gap: 2px 3px;
    font-size: 0.59rem;
  }

  .setting-row {
    min-height: 58px;
    padding: 8px 10px;
  }

  .control-label {
    font-size: 0.68rem;
  }

  .range-line {
    gap: 5px;
  }

  .range-line input {
    width: min(34vw, 130px);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }
}
