:root {
  --bg-a: #fff8cd;
  --bg-b: #c6f8ff;
  --bg-c: #ffd3ee;
  --ink: #241621;
  --line: #1e1324;
  --card: #fff;
  --danger: #dc4a63;
  --good: #2f7e63;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "M PLUS Rounded 1c", "Hiragino Kaku Gothic ProN", sans-serif;
  background:
    radial-gradient(circle at 14% 10%, var(--bg-a), transparent 44%),
    radial-gradient(circle at 90% 18%, var(--bg-b), transparent 42%),
    radial-gradient(circle at 35% 85%, var(--bg-c), transparent 50%),
    linear-gradient(145deg, #fffef8 0%, #f5fdff 52%, #fff4fc 100%);
}

.noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.03;
  background-image: radial-gradient(#000 0.5px, transparent 0.5px);
  background-size: 4px 4px;
  z-index: -1;
}

.game-header,
.game-layout {
  width: min(920px, calc(100% - 12px));
  margin: 0 auto;
}

.game-header {
  padding: 14px 2px 8px;
}

.header-links {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.nav-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  border: 2px solid var(--line);
  border-radius: 999px;
  background: #fff;
  padding: 5px 11px;
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--ink);
  box-shadow: 2px 2px 0 #00000020;
}

.kicker {
  display: inline-block;
  margin: 10px 0 0;
  padding: 4px 10px;
  border: 2px solid var(--line);
  border-radius: 999px;
  background: #ffe45c;
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.04em;
}

h1,
h2 {
  font-family: "Yusei Magic", "M PLUS Rounded 1c", sans-serif;
}

h1 {
  margin: 8px 0 6px;
  font-size: clamp(1.8rem, 7.4vw, 2.8rem);
  line-height: 1.04;
}

.lead {
  margin: 0;
  font-size: clamp(0.9rem, 3.8vw, 1rem);
  line-height: 1.45;
}

.game-layout {
  display: grid;
  gap: 12px;
  padding-bottom: 18px;
}

.card {
  border: 3px solid var(--line);
  border-radius: 20px;
  background: var(--card);
  box-shadow: 8px 8px 0 #0000001a;
}

.play-panel {
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.canvas-shell {
  position: relative;
  border: 0;
  border-radius: 16px;
  background: transparent;
  padding: 0;
  overflow: hidden;
}

#game-canvas {
  width: 100%;
  display: block;
  height: auto;
  border: 0;
  border-radius: 14px;
  touch-action: none;
  background: linear-gradient(180deg, #211b3f 0%, #171b37 58%, #11152e 100%);
}

.hud {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  display: grid;
  grid-template-columns: 25% 50% 25%;
  gap: 0;
  pointer-events: none;
}

.hud-item {
  border: 2px solid #190f22;
  border-radius: 0;
  padding: 5px 7px;
  background: #ffffffeb;
  box-shadow: 0 3px 0 #00000026;
  display: flex;
  align-items: center;
  min-height: 50px;
  min-width: 0;
  gap: 4px;
  overflow: hidden;
}

.hud .hud-item + .hud-item {
  margin-left: -2px;
}

.hud .hud-item:first-child {
  border-top-left-radius: 12px;
  border-bottom-left-radius: 12px;
}

.hud .hud-item:last-child {
  border-top-right-radius: 12px;
  border-bottom-right-radius: 12px;
}

.hud-item-danger {
  background: #ffeef2;
  border-color: #5f1d2d;
}

.hud-label {
  display: inline-block;
  font-size: 0.56rem;
  font-weight: 900;
  letter-spacing: 0.03em;
  white-space: nowrap;
  flex: 0 0 auto;
}

.hud-value {
  display: inline-block;
  font-size: 0.94rem;
  font-weight: 900;
  white-space: nowrap;
}

.hud-item-score,
.hud-item-danger {
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  gap: 2px;
}

.hud-item-score .hud-label,
.hud-item-danger .hud-label {
  display: block;
}

.hud-item-score .hud-value,
.hud-item-danger .hud-value {
  display: block;
  margin-left: 0;
}

.hud-item-current {
  justify-content: center;
  padding-left: 8px;
  padding-right: 8px;
}

.hud-current-wrap {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex: 1;
  min-height: 0;
  min-width: 0;
}

.hud-current-wrap.is-name-only {
  grid-template-columns: minmax(0, 1fr);
}

#current-shape-canvas {
  width: 74px;
  height: 52px;
  flex: 0 0 auto;
}

.hud-current-name {
  font-size: 1rem;
  font-weight: 900;
  line-height: 1.1;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
  text-align: left;
  min-width: 0;
}

#life-value {
  font-size: 1rem;
  letter-spacing: 0.06em;
  color: #d93a52;
}

.rotate-control {
  position: absolute;
  left: 50%;
  bottom: 10px;
  width: 222px;
  transform: translateX(-50%);
  z-index: 4;
}

.rotate-button {
  width: 100%;
  padding: 20px 0;
  font-size: 0.72rem;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

.overlay-screen,
.result-modal {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: #0f0a1694;
}

.overlay-screen[hidden],
.result-modal[hidden] {
  display: none;
}

.overlay-message,
.result-card {
  border: 3px solid var(--line);
  border-radius: 16px;
  background: #fff;
  box-shadow: 8px 8px 0 #00000022;
}

.overlay-message {
  max-width: 300px;
  margin: 0 0 12px;
  padding: 10px;
  text-align: center;
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.45;
}

.overlay-screen {
  flex-direction: column;
}

.mode-select {
  width: min(340px, 100%);
  margin: 0 0 10px;
  border: 3px solid var(--line);
  border-radius: 14px;
  background: #fff;
  box-shadow: 8px 8px 0 #00000022;
  padding: 8px 10px 10px;
}

.mode-select-label {
  margin: 0 0 6px;
  text-align: center;
  font-size: 0.75rem;
  font-weight: 800;
}

.mode-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.mode-tab {
  border: 2px solid var(--line);
  border-radius: 10px;
  padding: 7px 8px;
  font: inherit;
  font-size: 0.74rem;
  font-weight: 900;
  line-height: 1.1;
  color: var(--ink);
  background: #fff;
  box-shadow: 3px 3px 0 #55717a;
  cursor: pointer;
}

.mode-tab.active {
  background: linear-gradient(135deg, #ff4f96 0%, #ff6f48 100%);
  color: #fff;
  box-shadow: 3px 3px 0 #7b2b57;
}

.action-button,
.sub-button {
  border: 2px solid var(--line);
  border-radius: 12px;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 900;
  line-height: 1.2;
  cursor: pointer;
}

.action-button {
  background: linear-gradient(135deg, #ff4f96 0%, #ff6f48 100%);
  color: #fff;
  padding: 9px 12px;
  box-shadow: 4px 4px 0 #7b2b57;
}

.action-button:disabled {
  opacity: 0.6;
  cursor: default;
}

.sub-button {
  background: #fff;
  color: var(--ink);
  padding: 8px 11px;
  box-shadow: 4px 4px 0 #55717a;
}

.sub-button.rotate-button {
  width: 100%;
  padding: 20px 0;
}

.result-card {
  width: min(360px, 100%);
  padding: 14px;
}

.result-card h2 {
  margin: 0;
  font-size: 1.4rem;
}

.result-score,
.result-stats {
  margin: 10px 0 0;
  font-weight: 800;
}

.score-form {
  margin-top: 10px;
  display: grid;
  gap: 7px;
}

.score-form label {
  font-size: 0.8rem;
  font-weight: 700;
}

.score-form input {
  border: 2px solid #2f2138;
  border-radius: 10px;
  font: inherit;
  padding: 8px 10px;
  width: 100%;
}

.submit-message {
  min-height: 1.2rem;
  margin: 6px 0 0;
  font-size: 0.78rem;
  font-weight: 700;
}

.submit-message.error {
  color: var(--danger);
}

.submit-message.success {
  color: var(--good);
}

#retry-button {
  margin-top: 4px;
}

#share-cta-note {
  margin: 8px 2px 6px;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  font-size: 0.76rem;
  line-height: 1.45;
  font-weight: 800;
  color: #3a2945;
}

.share-cta-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 76px;
  gap: 6px;
  align-items: center;
  max-width: 290px;
  margin: 0;
}

@property --share-ring-angle {
  syntax: '<angle>';
  inherits: false;
  initial-value: 0deg;
}

#share-x-button {
  --share-ring-angle: 0deg;
  --share-ring-duration: 3s;
  margin-top: 0;
  position: relative;
  isolation: isolate;
  z-index: 0;
}

#share-x-button.share-main-button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 72px;
  padding: 6px 4px;
  text-align: center;
}

.share-main-line {
  display: block;
  line-height: 1.12;
  font-size: 0.74rem;
  font-weight: 900;
  letter-spacing: 0;
  color: #2f2138;
}

#share-x-button::before {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: 12px;
  z-index: -1;
  background: conic-gradient(
    from var(--share-ring-angle),
    #ff4f96 0deg,
    #ff7a59 60deg,
    #ffd76a 120deg,
    #72f28e 180deg,
    #50d8ff 240deg,
    #6f7bff 300deg,
    #ff4f96 360deg
  );
  animation: share-rainbow-flow var(--share-ring-duration) linear infinite;
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  padding: 2px;
}

#share-x-button.share-cta-boost::before {
  --share-ring-duration: 1.8s;
  filter: drop-shadow(0 0 6px #ff8ec6aa);
}

.share-preview {
  min-height: 72px;
  border: 2px solid var(--line);
  border-radius: 9px;
  background: #fff;
  box-shadow: 3px 3px 0 #55717a;
  overflow: hidden;
  display: grid;
  grid-template-rows: 12px 1fr;
}

.share-preview-label {
  display: grid;
  place-items: center;
  font-size: 0.42rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  color: #3e2b4b;
  background: linear-gradient(135deg, #f7f3ff 0%, #ecfbff 100%);
  border-bottom: 1px solid #b8a6ce;
}

#share-thumb-canvas {
  display: block;
  width: 100%;
  height: calc(100% - 0px);
  background: #1a1230;
}

@keyframes share-rainbow-flow {
  from {
    --share-ring-angle: 0deg;
  }
  to {
    --share-ring-angle: 360deg;
  }
}

.stream-note {
  margin: 10px 2px 0;
  font-size: 0.72rem;
  line-height: 1.45;
  color: #4e4258;
}

.stream-note a {
  color: inherit;
  text-underline-offset: 2px;
  font-weight: 800;
}

.ranking {
  padding: 12px;
}

.ranking h2 {
  margin: 0;
  font-size: 1.2rem;
}

.ranking-status {
  margin: 8px 0 0;
  font-size: 0.8rem;
  font-weight: 700;
}

.ranking-mode-tabs {
  margin-top: 8px;
}

.ranking-list {
  margin: 10px auto 0;
  width: 60%;
  min-width: 240px;
  list-style: none;
  padding: 0 8px 0 0;
  display: grid;
  gap: 6px;
  max-height: 70vh;
  overflow: auto;
}

.ranking-list li {
  border: 2px solid var(--line);
  border-radius: 10px;
  background: linear-gradient(125deg, #fffef7 0%, #fff6fd 100%);
  padding: 6px 8px;
  font-size: 0.8rem;
  font-weight: 800;
}

.audio-credit {
  width: min(920px, calc(100% - 12px));
  margin: 4px auto 14px;
  font-size: 0.68rem;
  line-height: 1.4;
  color: #4c3d52;
}

.audio-credit a {
  color: inherit;
}

@media (min-width: 768px) {
  .game-layout {
    grid-template-columns: minmax(0, 1fr) 300px;
    align-items: start;
  }

  .play-panel {
    padding: 0;
  }

  .canvas-shell {
    padding: 0;
  }

  .hud-label {
    font-size: 0.64rem;
  }

  .hud-value {
    font-size: 0.92rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  #share-x-button::before {
    animation: none;
  }

  #share-x-button.share-cta-boost::before {
    filter: none;
  }
}
