.kgrh-game {
  --kgrh-ink: #12233f;
  --kgrh-indigo: #173d66;
  --kgrh-deep: #07192d;
  --kgrh-cream: #f6eccf;
  --kgrh-paper: #fff8e7;
  --kgrh-gold: #e9b949;
  --kgrh-vermilion: #c83d2d;
  --kgrh-cyan: #7cd6d3;
  width: 100%;
  max-width: 980px;
  margin: 2rem auto;
  color: var(--kgrh-ink);
  font-family: "Yu Mincho", "Hiragino Mincho ProN", "Yu Gothic", "Hiragino Kaku Gothic ProN", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  isolation: isolate;
}

.kgrh-game,
.kgrh-game * {
  box-sizing: border-box;
}

.kgrh-game button {
  font: inherit;
}

.kgrh-game button:focus-visible,
.kgrh-game canvas:focus-visible {
  outline: 4px solid #fff;
  outline-offset: 3px;
  box-shadow: 0 0 0 7px var(--kgrh-vermilion);
}

.kgrh-frame {
  position: relative;
  overflow: hidden;
  border: 3px solid var(--kgrh-gold);
  border-radius: 24px;
  background:
    radial-gradient(circle at 82% 8%, rgba(233, 185, 73, 0.2) 0 11%, transparent 11.5%),
    repeating-linear-gradient(135deg, rgba(23, 61, 102, 0.035) 0 2px, transparent 2px 9px),
    var(--kgrh-paper);
  box-shadow:
    0 22px 50px rgba(7, 25, 45, 0.22),
    inset 0 0 0 6px rgba(255, 255, 255, 0.62),
    inset 0 0 0 8px var(--kgrh-indigo);
}

.kgrh-titlebar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 24px 14px;
  color: var(--kgrh-cream);
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.05), transparent 34%),
    var(--kgrh-deep);
  border-bottom: 3px solid var(--kgrh-gold);
}

.kgrh-game .kgrh-titlebar > div:last-child {
  min-width: 0;
}

.kgrh-title-seal {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 58px;
  height: 58px;
  border: 3px solid rgba(255, 248, 231, 0.9);
  border-radius: 6px;
  color: #fff;
  background: var(--kgrh-vermilion);
  box-shadow: inset 0 0 0 2px var(--kgrh-vermilion), inset 0 0 0 3px rgba(255, 255, 255, 0.55);
  font-weight: 900;
  font-size: 16px;
  letter-spacing: 0.1em;
  transform: rotate(-3deg);
}

.kgrh-kicker,
.kgrh-title,
.kgrh-score-note,
.kgrh-helper-note,
.kgrh-disclaimer,
.kgrh-panel p {
  margin: 0;
}

.kgrh-game .kgrh-kicker {
  position: static !important;
  display: block !important;
  width: auto !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  color: var(--kgrh-gold);
  background: transparent !important;
  box-shadow: none !important;
  font-family: "Yu Gothic", "Hiragino Kaku Gothic ProN", system-ui, sans-serif;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.28em;
  line-height: 1;
}

.kgrh-game .kgrh-title {
  position: static !important;
  display: block !important;
  width: auto !important;
  max-width: none !important;
  min-height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  color: #fff;
  background: transparent !important;
  box-shadow: none !important;
  font-size: clamp(22px, 4.2vw, 42px);
  font-weight: 900;
  line-height: 1.12;
  letter-spacing: 0.02em;
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.34);
}

.kgrh-game .kgrh-title span {
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  color: var(--kgrh-gold);
  background: transparent !important;
  box-shadow: none !important;
}

.kgrh-game .kgrh-title::before,
.kgrh-game .kgrh-title::after,
.kgrh-game .kgrh-panel h3::before,
.kgrh-game .kgrh-panel h3::after,
.kgrh-game .kgrh-learning-title::before,
.kgrh-game .kgrh-learning-title::after {
  display: none !important;
  content: none !important;
}

.kgrh-hud {
  position: relative;
  z-index: 4;
  display: grid;
  grid-template-columns: minmax(120px, 1.3fr) minmax(135px, 1fr) repeat(2, minmax(82px, 0.78fr)) 54px;
  gap: 8px;
  padding: 10px 12px;
  color: var(--kgrh-cream);
  background: var(--kgrh-indigo);
  font-family: "Yu Gothic", "Hiragino Kaku Gothic ProN", system-ui, sans-serif;
}

.kgrh-meter {
  min-width: 0;
  padding: 6px 12px;
  border: 1px solid rgba(233, 185, 73, 0.5);
  border-radius: 9px;
  background: rgba(7, 25, 45, 0.42);
  text-align: center;
}

.kgrh-meter-label {
  display: block;
  color: rgba(246, 236, 207, 0.74);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  line-height: 1.2;
}

.kgrh-meter strong {
  display: inline-block;
  color: #fff;
  font-size: clamp(18px, 3vw, 27px);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.kgrh-meter small {
  margin-left: 2px;
  color: var(--kgrh-gold);
  font-size: 10px;
}

.kgrh-score-meter strong {
  color: var(--kgrh-gold);
}

.kgrh-life-meter {
  overflow: hidden;
  padding-right: 5px;
  padding-left: 5px;
}

.kgrh-lives {
  display: block !important;
  width: 100%;
  color: #f36c54 !important;
  font-size: clamp(13px, 2.15vw, 20px) !important;
  letter-spacing: 0.02em;
  line-height: 1.18 !important;
  text-align: center;
  white-space: nowrap;
}

.kgrh-special-status {
  color: var(--kgrh-gold) !important;
  font-size: clamp(15px, 2.5vw, 22px) !important;
}

.kgrh-special-meter.is-used .kgrh-special-status {
  color: #8d9aae !important;
}

.kgrh-sound {
  display: grid;
  place-items: center;
  width: 50px;
  height: 50px;
  align-self: center;
  border: 2px solid var(--kgrh-gold);
  border-radius: 50%;
  color: var(--kgrh-deep);
  background: var(--kgrh-gold);
  box-shadow: 0 3px 0 #90671a;
  cursor: pointer;
  font-weight: 900;
  font-size: 14px;
  transition: transform 150ms ease, filter 150ms ease;
}

.kgrh-sound:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.kgrh-sound:active {
  box-shadow: 0 1px 0 #90671a;
  transform: translateY(2px);
}

.kgrh-sound[aria-pressed="true"] {
  color: var(--kgrh-cream);
  background: #5a6980;
  box-shadow: none;
  text-decoration: line-through;
}

.kgrh-stage {
  position: relative;
  overflow: hidden;
  width: 100%;
  aspect-ratio: 3 / 2;
  min-height: 300px;
  max-height: min(68vh, 660px);
  background: var(--kgrh-deep);
  touch-action: manipulation;
}

.kgrh-canvas {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  cursor: crosshair;
  touch-action: none;
}

.kgrh-flash {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  opacity: 0;
  background: rgba(200, 61, 45, 0.25);
}

.kgrh-flash.is-hit {
  animation: kgrh-screen-hit 280ms ease-out;
}

.kgrh-flash.is-recover {
  background: rgba(242, 196, 81, 0.3);
  animation: kgrh-screen-recover 520ms ease-out;
}

.kgrh-announcer {
  position: absolute;
  z-index: 3;
  top: 14%;
  left: 50%;
  width: max-content;
  max-width: 90%;
  pointer-events: none;
  color: #fff;
  font-size: clamp(22px, 5vw, 48px);
  font-weight: 900;
  line-height: 1;
  letter-spacing: 0.05em;
  opacity: 0;
  text-align: center;
  text-shadow:
    3px 3px 0 var(--kgrh-vermilion),
    -2px -2px 0 var(--kgrh-vermilion),
    0 6px 12px rgba(0, 0, 0, 0.45);
  transform: translate(-50%, 20px) rotate(-3deg) scale(0.75);
}

.kgrh-announcer.is-showing {
  animation: kgrh-announcement 850ms cubic-bezier(0.2, 0.85, 0.25, 1);
}

.kgrh-announcer.is-perfect {
  color: var(--kgrh-gold);
  text-shadow:
    3px 3px 0 var(--kgrh-vermilion),
    -2px -2px 0 var(--kgrh-vermilion),
    0 6px 12px rgba(0, 0, 0, 0.45);
}

.kgrh-overlay {
  position: absolute;
  z-index: 5;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(7, 25, 45, 0.7);
  backdrop-filter: blur(5px);
}

.kgrh-overlay.is-visible {
  display: flex;
}

.kgrh-panel {
  position: relative;
  width: min(92%, 530px);
  padding: clamp(22px, 5vw, 42px);
  border: 3px solid var(--kgrh-gold);
  border-radius: 18px;
  color: var(--kgrh-ink);
  background:
    repeating-linear-gradient(0deg, rgba(23, 61, 102, 0.03) 0 1px, transparent 1px 6px),
    var(--kgrh-paper);
  box-shadow:
    0 16px 40px rgba(0, 0, 0, 0.35),
    inset 0 0 0 5px rgba(255, 255, 255, 0.72),
    inset 0 0 0 7px var(--kgrh-indigo);
  text-align: center;
}

.kgrh-panel::before,
.kgrh-panel::after {
  position: absolute;
  top: 14px;
  bottom: 14px;
  width: 4px;
  content: "";
  background: repeating-linear-gradient(to bottom, var(--kgrh-vermilion) 0 12px, transparent 12px 20px);
  opacity: 0.7;
}

.kgrh-panel::before {
  left: 14px;
}

.kgrh-panel::after {
  right: 14px;
}

.kgrh-game .kgrh-panel h3 {
  position: static !important;
  width: auto !important;
  max-width: none !important;
  margin: 0 0 12px;
  padding: 0 !important;
  border: 0 !important;
  color: var(--kgrh-indigo);
  background: transparent !important;
  box-shadow: none !important;
  font-size: clamp(24px, 5vw, 38px);
  font-weight: 900;
  line-height: 1.2;
}

.kgrh-panel p {
  font-family: "Yu Gothic", "Hiragino Kaku Gothic ProN", system-ui, sans-serif;
  font-size: clamp(13px, 2.2vw, 17px);
}

.kgrh-panel-mark {
  display: grid;
  width: 52px;
  height: 52px;
  margin: -10px auto 12px !important;
  place-items: center;
  border: 3px solid rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  color: #fff;
  background: var(--kgrh-vermilion);
  box-shadow: 0 0 0 3px var(--kgrh-vermilion);
  font-family: "Yu Mincho", "Hiragino Mincho ProN", serif !important;
  font-size: 19px !important;
  font-weight: 900;
  transform: rotate(-5deg);
}

.kgrh-mini-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin: 18px 0;
  font-family: "Yu Gothic", "Hiragino Kaku Gothic ProN", system-ui, sans-serif;
  font-size: 12px;
}

.kgrh-mini-legend span {
  padding: 7px 10px;
  border-radius: 999px;
  color: var(--kgrh-indigo);
  background: rgba(23, 61, 102, 0.09);
}

.kgrh-mini-legend b {
  color: var(--kgrh-vermilion);
}

.kgrh-mini-legend .kgrh-yatagarasu-help {
  border: 1px solid rgba(175, 116, 17, 0.36);
  background: rgba(233, 185, 73, 0.24);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.48);
}

.kgrh-mini-legend .kgrh-yatagarasu-help b {
  color: #8b5c0b;
}

.kgrh-primary {
  min-width: 190px;
  margin-top: 4px;
  padding: 13px 26px;
  border: 2px solid #7d2017;
  border-radius: 999px;
  color: #fff;
  background: linear-gradient(#de5643, var(--kgrh-vermilion));
  box-shadow: 0 5px 0 #7d2017, 0 8px 14px rgba(0, 0, 0, 0.18);
  cursor: pointer;
  font-family: "Yu Gothic", "Hiragino Kaku Gothic ProN", system-ui, sans-serif !important;
  font-weight: 900;
  letter-spacing: 0.08em;
  transition: filter 150ms ease, transform 150ms ease;
}

.kgrh-primary:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.kgrh-primary:active {
  box-shadow: 0 2px 0 #7d2017;
  transform: translateY(3px);
}

.kgrh-small-panel {
  max-width: 420px;
}

.kgrh-result-panel {
  width: min(96%, 620px);
  max-height: calc(100% - 8px);
  padding-top: 28px;
  overflow-y: auto;
}

.kgrh-result-rank {
  display: inline-block;
  margin-bottom: 8px !important;
  padding: 4px 14px;
  border-radius: 999px;
  color: #fff;
  background: var(--kgrh-vermilion);
  font-weight: 900;
  letter-spacing: 0.14em;
}

.kgrh-result-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 17px 0;
}

.kgrh-result-grid div {
  padding: 12px 7px;
  border: 1px solid rgba(23, 61, 102, 0.2);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.64);
}

.kgrh-result-grid span,
.kgrh-result-grid strong,
.kgrh-result-grid small {
  display: block;
}

.kgrh-result-grid span {
  color: #68748a;
  font-family: "Yu Gothic", "Hiragino Kaku Gothic ProN", system-ui, sans-serif;
  font-size: 11px;
  font-weight: 700;
}

.kgrh-result-grid strong {
  color: var(--kgrh-indigo);
  font-family: "Yu Gothic", "Hiragino Kaku Gothic ProN", system-ui, sans-serif;
  font-size: clamp(22px, 4vw, 35px);
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}

.kgrh-result-grid small {
  color: var(--kgrh-vermilion);
  font-size: 10px;
}

.kgrh-new-record {
  margin: -4px 0 12px !important;
  color: var(--kgrh-vermilion);
  font-weight: 900;
}

.kgrh-learning {
  position: relative;
  margin: 10px 0 8px;
  padding: 14px 16px 13px 54px;
  border: 2px solid rgba(23, 61, 102, 0.2);
  border-radius: 13px;
  background: linear-gradient(100deg, rgba(233, 185, 73, 0.2), rgba(255, 255, 255, 0.72));
  text-align: left;
}

.kgrh-learning-mark {
  position: absolute;
  top: 15px;
  left: 14px;
  display: grid;
  width: 29px;
  height: 29px;
  place-items: center;
  border-radius: 50%;
  border: 7px double var(--kgrh-paper);
  background: var(--kgrh-indigo);
  box-shadow: 0 0 0 2px var(--kgrh-indigo);
}

.kgrh-learning-kicker {
  color: var(--kgrh-vermilion);
  font-size: 10px !important;
  font-weight: 900;
  letter-spacing: 0.12em;
}

.kgrh-game .kgrh-learning-title {
  position: static !important;
  width: auto !important;
  max-width: none !important;
  margin: 1px 0 4px;
  padding: 0 !important;
  border: 0 !important;
  color: var(--kgrh-indigo);
  background: transparent !important;
  box-shadow: none !important;
  font-family: "Yu Gothic", "Hiragino Kaku Gothic ProN", system-ui, sans-serif;
  font-size: clamp(15px, 2.5vw, 19px);
  line-height: 1.25;
}

.kgrh-learning-text {
  color: #263d5a;
  font-size: clamp(11px, 1.9vw, 13px) !important;
  font-weight: 600;
  line-height: 1.58 !important;
}

.kgrh-learning-note {
  margin: 0 0 8px !important;
  color: #68748a;
  font-size: 9px !important;
  line-height: 1.4 !important;
}

.kgrh-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 16px;
  padding: 13px 16px 9px;
  border-top: 3px solid var(--kgrh-gold);
  color: var(--kgrh-indigo);
  background: var(--kgrh-cream);
  font-family: "Yu Gothic", "Hiragino Kaku Gothic ProN", system-ui, sans-serif;
  font-size: 12px;
  font-weight: 700;
}

.kgrh-legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.kgrh-legend b {
  color: var(--kgrh-vermilion);
  font-size: 10px;
}

.kgrh-dot {
  width: 10px;
  height: 10px;
  border: 2px solid rgba(7, 25, 45, 0.3);
  border-radius: 50%;
}

.kgrh-dot-kosa { background: #d9a344; }
.kgrh-dot-wind { background: #72d6c9; }
.kgrh-dot-cold { background: #a8ddf0; }
.kgrh-dot-rain { background: #6472b8; }
.kgrh-dot-depression { background: #45b8b7; }
.kgrh-dot-typhoon { background: #e85b54; }

.kgrh-score-note {
  padding: 0 16px 4px;
  color: #7d2017;
  background: var(--kgrh-cream);
  font-family: "Yu Gothic", "Hiragino Kaku Gothic ProN", system-ui, sans-serif;
  font-size: 10px;
  font-weight: 800;
  line-height: 1.45;
  text-align: center;
}

.kgrh-helper-note {
  padding: 10px 16px 7px;
  color: #6d4a0d;
  background: var(--kgrh-cream);
  font-family: "Yu Gothic", "Hiragino Kaku Gothic ProN", system-ui, sans-serif;
  font-size: 11px;
  font-weight: 800;
  line-height: 1.45;
  text-align: center;
}

.kgrh-helper-note span {
  color: var(--kgrh-gold);
  text-shadow: 0 1px 0 #74511b;
}

.kgrh-disclaimer {
  padding: 0 16px 13px;
  color: #68748a;
  background: var(--kgrh-cream);
  font-family: "Yu Gothic", "Hiragino Kaku Gothic ProN", system-ui, sans-serif;
  font-size: 10px;
  text-align: center;
}

@keyframes kgrh-announcement {
  0% { opacity: 0; transform: translate(-50%, 20px) rotate(-3deg) scale(0.75); }
  20% { opacity: 1; transform: translate(-50%, 0) rotate(-3deg) scale(1.08); }
  65% { opacity: 1; transform: translate(-50%, 0) rotate(-3deg) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -18px) rotate(-3deg) scale(0.98); }
}

@keyframes kgrh-screen-hit {
  0% { opacity: 0; }
  35% { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes kgrh-screen-recover {
  0% { opacity: 0; }
  25% { opacity: 1; }
  100% { opacity: 0; }
}

@media (max-width: 680px) {
  .kgrh-game {
    margin: 1rem auto;
  }

  .kgrh-frame {
    border-radius: 16px;
  }

  .kgrh-titlebar {
    gap: 10px;
    padding: 12px 14px 10px;
  }

  .kgrh-game .kgrh-kicker {
    margin-bottom: -1px !important;
  }

  .kgrh-title-seal {
    width: 44px;
    height: 44px;
    border-width: 2px;
    font-size: 12px;
  }

  .kgrh-game .kgrh-title span {
    display: block;
    font-size: 0.88em;
  }

  .kgrh-hud {
    grid-template-columns: 1.08fr 1.18fr 0.72fr 0.82fr 38px;
    gap: 4px;
    padding: 7px;
  }

  .kgrh-meter {
    padding: 5px 3px;
  }

  .kgrh-meter-label {
    font-size: 8px;
    letter-spacing: 0.02em;
  }

  .kgrh-lives {
    font-size: 11px !important;
    letter-spacing: 0;
  }

  .kgrh-sound {
    width: 38px;
    height: 38px;
    font-size: 11px;
  }

  .kgrh-stage {
    min-height: 330px;
    aspect-ratio: 4 / 5;
    max-height: 72vh;
  }

  .kgrh-panel {
    padding: 15px 20px 18px;
  }

  .kgrh-result-overlay {
    padding: 4px;
  }

  .kgrh-panel::before,
  .kgrh-panel::after {
    top: 9px;
    bottom: 9px;
  }

  .kgrh-game .kgrh-panel h3 {
    margin-bottom: 7px;
    font-size: 22px;
  }

  .kgrh-panel p {
    font-size: 12px;
    line-height: 1.4;
  }

  .kgrh-panel-mark {
    width: 40px;
    height: 40px;
    margin: 0 auto 8px !important;
    font-size: 15px !important;
  }

  .kgrh-mini-legend {
    flex-direction: column;
    gap: 5px;
    margin: 8px auto;
  }

  .kgrh-mini-legend span {
    padding: 3px 8px;
  }

  .kgrh-primary {
    padding: 10px 22px;
  }

  .kgrh-result-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 5px;
  }

  .kgrh-result-grid div {
    padding: 6px 2px;
  }

  .kgrh-result-panel {
    width: 100%;
    padding: 10px 14px 12px;
  }

  .kgrh-result-rank {
    margin-bottom: 4px !important;
    padding: 2px 10px;
  }

  .kgrh-result-grid {
    margin: 8px 0;
  }

  .kgrh-result-grid span {
    font-size: 9px;
    white-space: nowrap;
  }

  .kgrh-result-grid strong {
    font-size: 20px;
  }

  .kgrh-result-grid small {
    font-size: 8px;
  }

  .kgrh-new-record {
    margin: -2px 0 5px !important;
    font-size: 11px !important;
  }

  .kgrh-learning {
    margin: 7px 0 5px;
    padding: 9px 10px 9px 42px;
  }

  .kgrh-learning-mark {
    top: 10px;
    left: 9px;
    width: 25px;
    height: 25px;
    font-size: 13px;
  }

  .kgrh-learning-text {
    line-height: 1.45 !important;
  }

  .kgrh-legend {
    gap: 6px 10px;
    font-size: 10px;
  }

  .kgrh-helper-note {
    padding: 8px 12px 6px;
    font-size: 10px;
  }

  .kgrh-score-note {
    padding: 0 10px 3px;
    font-size: 9px;
  }
}

@media (max-width: 370px) {
  .kgrh-game .kgrh-title {
    font-size: 19px;
  }

  .kgrh-game .kgrh-kicker {
    font-size: 8px;
  }

  .kgrh-title-seal {
    width: 38px;
    height: 38px;
  }

  .kgrh-hud {
    grid-template-columns: 1fr 1.25fr 0.68fr 0.8fr 33px;
  }

  .kgrh-meter strong {
    font-size: 16px;
  }

  .kgrh-lives {
    font-size: 10px !important;
  }

  .kgrh-sound {
    width: 33px;
    height: 33px;
  }
}

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