:root {
  --red: #ff2d2d;
  --yellow: #ffbb00;
  --blue: #00c6ff;
  --green: #2ecc71;
  --ink: #111111;
  --paper: #ffffff;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  background:
    radial-gradient(circle at 25% 16%, rgba(255, 187, 0, 0.2), transparent 24%),
    radial-gradient(circle at 80% 74%, rgba(255, 45, 45, 0.16), transparent 28%),
    linear-gradient(135deg, #ffffff 0%, #eeeeee 52%, #dcdcdc 100%);
  color: var(--ink);
  font-family:
    "Arial Black", "Yu Gothic", "Meiryo", system-ui, sans-serif;
  overflow-x: hidden;
  overscroll-behavior: none;
}

button {
  font: inherit;
  border: 0;
  cursor: pointer;
}

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(330px, 450px) minmax(260px, 360px);
  gap: 28px;
  align-items: center;
  justify-content: center;
  padding: 28px;
}

.phone-frame {
  position: relative;
  width: min(94vw, 430px);
  aspect-ratio: 390 / 720;
  border: 0;
  border-radius: 0;
  overflow: hidden;
  box-shadow: 0 20px 54px rgba(0, 0, 0, 0.24);
  background: #111111;
}

#game {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  user-select: none;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 24px;
  text-align: center;
}

.hidden {
  display: none !important;
}

.title-overlay {
  justify-content: flex-start;
  padding-top: 44px;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.08), rgba(0, 0, 0, 0.62)),
    url("./assets/ui/title_background.png") center / cover;
}

.title-overlay::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.88), rgba(255, 255, 255, 0.34)),
    radial-gradient(circle at 50% 72%, rgba(255, 187, 0, 0.34), transparent 34%);
}

.title-overlay > * {
  position: relative;
  z-index: 1;
}

.logo-mark {
  width: 100%;
  max-width: 350px;
  padding: 8px 10px 12px;
  color: #ffffff;
  text-align: left;
  transform: rotate(-4deg);
  filter: drop-shadow(0 8px 0 #000000);
}

.logo-mark span {
  display: block;
  color: #ffffff;
  font-size: 34px;
  line-height: 0.95;
  text-shadow:
    3px 3px 0 #000000,
    -3px 3px 0 #000000,
    3px -3px 0 #000000,
    -3px -3px 0 #000000;
}

.logo-mark strong {
  display: block;
  color: var(--red);
  font-size: 58px;
  line-height: 0.9;
  letter-spacing: 0;
  text-shadow:
    4px 4px 0 #000000,
    -3px 3px 0 #000000,
    0 0 10px rgba(255, 187, 0, 0.9);
}

.tagline {
  width: 100%;
  margin: 8px 0 4px;
  padding: 10px 12px;
  color: #ffffff;
  background: #111111;
  border-left: 8px solid var(--yellow);
  border-right: 8px solid var(--red);
  font-size: 18px;
}

.mode-list {
  width: 100%;
  display: grid;
  gap: 10px;
}

.mode-card {
  min-height: 62px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 2px;
  align-content: center;
  padding: 9px 14px;
  color: #ffffff;
  background: linear-gradient(180deg, #2e2e2e, #121212);
  border: 2px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  text-align: left;
}

.mode-card.active {
  background: linear-gradient(180deg, #ff3b24, #d10d00);
  border-color: var(--yellow);
  box-shadow: 0 0 0 3px rgba(255, 187, 0, 0.28);
}

.mode-card b {
  font-size: 18px;
}

.mode-card span {
  font-family: "Yu Gothic", "Meiryo", system-ui, sans-serif;
  font-weight: 700;
  font-size: 12px;
}

.difficulty-row {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.diff {
  min-height: 36px;
  color: #ffffff;
  background: #1b1b1b;
  border-radius: 6px;
  font-size: 12px;
  border: 2px solid rgba(255, 255, 255, 0.16);
}

.diff.active {
  color: #111111;
  background: var(--yellow);
  border-color: #ffffff;
}

.title-actions {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 0.58fr 0.72fr;
  gap: 8px;
}

.primary-btn,
.ghost-btn {
  min-height: 48px;
  border-radius: 7px;
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.22);
}

.primary-btn {
  color: #111111;
  background: linear-gradient(180deg, #ffe453, #ffb800);
  border: 2px solid #ffffff;
}

.ghost-btn {
  color: #ffffff;
  background: linear-gradient(180deg, #313131, #121212);
  border: 2px solid rgba(255, 255, 255, 0.18);
}

.card-overlay {
  width: calc(100% - 42px);
  height: auto;
  min-height: 360px;
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
  color: #ffffff;
  background:
    linear-gradient(180deg, rgba(28, 28, 28, 0.98), rgba(7, 7, 7, 0.98));
  border: 2px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.4);
}

.card-overlay h1,
.result-overlay h1 {
  margin: 0;
  font-size: 34px;
  color: #ffffff;
  text-shadow: 3px 3px 0 #000000;
}

.tutorial-grid,
.ranking-list {
  width: 100%;
  display: grid;
  gap: 9px;
}

.tutorial-grid p,
.ranking-list div {
  margin: 0;
  padding: 12px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  font-family: "Yu Gothic", "Meiryo", system-ui, sans-serif;
  font-weight: 700;
  text-align: left;
}

.toggle-line {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
}

.result-overlay {
  color: #ffffff;
  background:
    radial-gradient(circle at 50% 50%, rgba(255, 187, 0, 0.18), transparent 34%),
    linear-gradient(180deg, rgba(0, 0, 0, 0.75), rgba(0, 0, 0, 0.92));
}

.result-overlay .title-actions {
  max-width: 270px;
  grid-template-columns: 1fr 1fr;
}

.ribbon {
  padding: 8px 24px;
  color: #ffffff;
  background: var(--red);
  transform: rotate(-2deg);
  box-shadow: 0 4px 0 #6e0000;
}

.result-score {
  font-size: 58px;
  line-height: 1;
  color: #ffffff;
  text-shadow: 4px 4px 0 #000000;
}

.result-meta {
  display: flex;
  gap: 16px;
  font-family: "Yu Gothic", "Meiryo", system-ui, sans-serif;
  font-weight: 900;
}

.rank-badge {
  width: 116px;
  height: 116px;
  display: grid;
  place-items: center;
  color: var(--yellow);
  font-size: 64px;
  border: 5px solid var(--yellow);
  border-radius: 50%;
  text-shadow: 3px 3px 0 #000000;
  box-shadow: 0 0 30px rgba(255, 187, 0, 0.34);
}

.side-panel {
  max-width: 360px;
  padding: 24px;
  color: #ffffff;
  background: #111111;
  border-left: 8px solid var(--yellow);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.24);
}

.side-panel h2 {
  margin: 0 0 12px;
  font-size: 30px;
}

.side-panel p,
.side-panel li {
  font-family: "Yu Gothic", "Meiryo", system-ui, sans-serif;
  font-weight: 700;
  line-height: 1.65;
}

@media (max-width: 820px) {
  html,
  body {
    height: 100%;
    min-height: 100dvh;
    background: #111111;
    overflow: hidden;
  }

  .app {
    grid-template-columns: 1fr;
    width: 100vw;
    min-height: 100dvh;
    padding: 0;
    display: block;
  }

  .side-panel {
    display: none;
  }

  .phone-frame {
    width: 100vw;
    height: 100dvh;
    height: 100svh;
    max-width: none;
    aspect-ratio: auto;
    box-shadow: none;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
    background: #111111;
  }

  .overlay {
    padding: max(14px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right))
      max(14px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  }

  .title-overlay {
    padding-top: max(26px, env(safe-area-inset-top));
  }

  .logo-mark span {
    font-size: clamp(28px, 8.5vw, 34px);
  }

  .logo-mark strong {
    font-size: clamp(46px, 14vw, 58px);
  }

  .card-overlay {
    width: calc(100% - 28px);
    max-height: calc(100dvh - 28px);
    overflow: auto;
  }
}
