:root {
  color-scheme: light;
  --ink: #45323a;
  --muted: #866873;
  --paper: #fff8ee;
  --sakura: #f6a7b8;
  --beni: #d94f70;
  --matsu: #2e7d6b;
  --gold: #f4bd55;
}

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

html,
body {
  margin: 0;
  min-height: 100%;
  overflow: hidden;
  touch-action: none;
  background:
    radial-gradient(circle at 18% 12%, rgba(255, 255, 255, .82) 0 9px, transparent 10px),
    radial-gradient(circle at 80% 18%, rgba(255, 255, 255, .68) 0 7px, transparent 8px),
    linear-gradient(135deg, #ffe8e0 0%, #fff8ee 44%, #d8f0e5 100%);
  color: var(--ink);
  font-family: ui-rounded, "Hiragino Maru Gothic ProN", "Yu Gothic", system-ui, sans-serif;
}

button {
  border: 0;
  color: var(--ink);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.app {
  display: grid;
  min-height: 100svh;
  place-items: center;
  padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
}

.stage {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  gap: 10px;
  width: min(100%, 540px);
  height: calc(100svh - max(22px, env(safe-area-inset-top)) - max(22px, env(safe-area-inset-bottom)));
  max-height: 900px;
}

.topbar,
.queue,
.controls {
  display: grid;
  align-items: center;
  border: 2px solid rgba(69, 50, 58, .13);
  background: rgba(255, 252, 245, .78);
  box-shadow: 0 10px 28px rgba(125, 76, 77, .13);
  backdrop-filter: blur(8px);
}

.topbar {
  grid-template-columns: 1fr auto 1fr;
  min-height: 70px;
  padding: 8px 14px;
  border-radius: 8px;
}

.topbar > div:last-child {
  text-align: right;
}

h1 {
  margin: 0;
  color: var(--beni);
  font-size: clamp(1.25rem, 5.2vw, 2rem);
  letter-spacing: 0;
  white-space: nowrap;
}

.label {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: .72rem;
  font-weight: 700;
}

strong {
  font-size: 1.25rem;
}

.game-wrap {
  position: relative;
  min-height: 0;
  border: 3px solid #6f4b51;
  border-radius: 8px;
  overflow: hidden;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, .34) 1px, transparent 1px) 0 0 / 40px 40px,
    linear-gradient(0deg, rgba(255, 255, 255, .25) 1px, transparent 1px) 0 0 / 40px 40px,
    linear-gradient(#fff9ed 0%, #ffe9df 72%, #f8d7c8 100%);
  box-shadow: inset 0 -14px 0 rgba(127, 78, 62, .12), 0 18px 34px rgba(89, 52, 58, .18);
}

#game {
  display: block;
  width: 100%;
  height: 100%;
}

.aim {
  position: absolute;
  top: 8px;
  width: 3px;
  height: 96px;
  border-radius: 99px;
  background: repeating-linear-gradient(to bottom, rgba(217, 79, 112, .75) 0 10px, transparent 10px 17px);
  pointer-events: none;
  transform: translateX(-50%);
}

.notice {
  position: absolute;
  inset: 0;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 8px;
  width: 100%;
  height: 100%;
  border: 0;
  background: rgba(255, 248, 238, .84);
  color: var(--beni);
  text-align: center;
}

.notice[hidden] {
  display: none;
}

.notice strong {
  font-size: 2rem;
}

.controls {
  grid-template-columns: 58px 1fr 58px 58px;
  gap: 8px;
  padding: 8px;
  border-radius: 8px;
}

.controls button {
  min-height: 50px;
  border-radius: 8px;
  background: #fff8ee;
  box-shadow: inset 0 -4px 0 rgba(69, 50, 58, .12);
}

#drop {
  color: white;
  background: linear-gradient(180deg, #f47c98, #d94f70);
  box-shadow: inset 0 -5px 0 rgba(106, 31, 51, .18);
}

.queue {
  grid-template-columns: auto auto minmax(150px, 1fr);
  justify-content: center;
  column-gap: 14px;
  row-gap: 0;
  min-height: 70px;
  padding: 6px 12px;
  border-radius: 8px;
  color: var(--muted);
  font-size: .72rem;
  font-weight: 800;
}

.queue:has(> .queue-item) {
  grid-template-columns: auto auto minmax(150px, 1fr);
  justify-content: stretch;
  gap: 14px;
}

.queue-item {
  display: grid;
  grid-template-rows: auto 44px;
  align-items: center;
  justify-content: center;
  justify-items: center;
  gap: 2px;
  min-width: 0;
  height: 58px;
}

.queue > span,
.queue-item span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 12px;
  line-height: 1;
  align-self: center;
}

.queue-label {
  font-size: .68rem;
}

.queue canvas {
  display: block;
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  align-self: center;
}

.settings {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  min-height: 24px;
  color: var(--muted);
  font-size: .66rem;
  font-weight: 800;
}

.settings .switch {
  display: inline-grid;
  grid-template-columns: auto 28px;
  align-items: center;
  gap: 6px;
  min-height: 24px;
  padding: 0 5px 0 8px;
  border: 2px solid rgba(69, 50, 58, .13);
  border-radius: 999px;
  background: rgba(255, 252, 245, .86);
  color: var(--muted);
  font-size: .66rem;
}

.settings .switch i {
  position: relative;
  display: block;
  width: 28px;
  height: 16px;
  border-radius: 999px;
  background: rgba(69, 50, 58, .18);
}

.settings .switch i::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 1px 3px rgba(69, 50, 58, .22);
  transition: transform .16s ease;
}

.settings .switch.is-on {
  background: var(--matsu);
  color: white;
}

.settings .switch.is-on i {
  background: rgba(255, 255, 255, .34);
}

.settings .switch.is-on i::after {
  transform: translateX(12px);
}

.queue-meta {
  display: grid;
  align-content: center;
  justify-items: end;
  gap: 3px;
  min-width: 0;
}

.install-hint {
  margin: 0;
  max-width: 260px;
  color: var(--muted);
  font-size: .62rem;
  font-weight: 800;
  line-height: 1.22;
  text-align: right;
}

@media (min-width: 740px) {
  .stage {
    width: min(92vw, 620px);
  }
}

@media (max-height: 680px) {
  .topbar {
    min-height: 58px;
  }

  .controls button {
    min-height: 44px;
  }

  .queue {
    display: none;
  }
}

@media (max-width: 430px) {
  .queue:has(> .queue-item) {
    grid-template-columns: auto auto;
    justify-content: center;
  }

  .queue-meta {
    display: none;
  }
}
