body {
  margin: 0;
  background: #f0f0f0;
  color: #1a2330;
  font-family: "Segoe UI", "Yu Gothic UI", Meiryo, "Malgun Gothic", "Microsoft YaHei", "PingFang SC", "Nirmala UI", "Leelawadee UI", Ebrima, Nyala, "Myanmar Text", "Khmer UI", "Lao UI", "MV Boli", Sylfaen, "Microsoft Himalaya", system-ui, sans-serif;
  line-height: 1.5;
}

a { color: #1a4f78; }

:focus-visible {
  outline: 2px solid #4facfe;
  outline-offset: 2px;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 18px;
  padding: 12px 16px;
  background: #1a3a52;
  color: #e7f6ff;
}

.topbar a { color: #e7f6ff; text-decoration: none; }

.brand { font-weight: 700; margin-inline-end: auto; }

.docnav, .foot-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
}

.docnav a[aria-current="page"],
.foot-links a[aria-current="page"] { text-decoration: underline; }

.langpick {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.92rem;
}

.langpick select {
  font: inherit;
  max-width: 240px;
  padding: 6px 8px;
  border-radius: 6px;
  border: 0;
  background: #fff;
  color: #1a3a52;
}

h1 {
  text-align: center;
  margin: 20px 16px 8px;
  color: #1a3a52;
  font-size: 1.8rem;
}

.content {
  width: min(1100px, calc(100% - 24px));
  height: min(750px, calc(100vh - 150px));
  min-height: 560px;
  margin: 12px auto 20px;
  border: 2px solid #ccc;
  border-radius: 10px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  position: relative;
  background: #d5e3ee;
}

.content:fullscreen,
.content:-webkit-full-screen {
  width: 100%;
  height: 100%;
  max-width: none;
  margin: 0;
  border: none;
  border-radius: 0;
}

#game {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-sizing: border-box;
  background: linear-gradient(180deg, #eef5fb 0%, #d5e3ee 100%);
  color: #1a3a52;
  user-select: none;
}

#game * { box-sizing: border-box; }

#hud {
  position: relative;
  z-index: 2;
  padding: 12px 16px 8px;
  text-align: center;
}

#counter {
  font-family: ui-monospace, "Courier New", monospace;
  font-weight: 700;
  line-height: 0.95;
  font-size: 5rem;
  letter-spacing: -0.03em;
}

#perSecond { margin: 6px 0 10px; font-size: 1.15rem; }

.spacebar-key {
  display: block;
  width: min(92%, 640px);
  margin: 0 auto;
  padding: 26px 12px 8px;
  border: 5px solid #1a3a52;
  border-bottom-width: 20px;
  border-radius: 14px;
  background: linear-gradient(180deg, #f4fbff 0%, #9ec3d8 100%);
  color: #5d7f96;
  font: inherit;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.45em;
  text-indent: 0.45em;
  cursor: pointer;
  touch-action: manipulation;
}

.spacebar-key:hover { color: #1a3a52; }

.spacebar-key.is-down {
  border-bottom-width: 10px;
  padding-top: 32px;
  transform: translateY(4px);
  color: #1a3a52;
}

.hud-actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.hud-actions button,
.top-head button,
#topForm button,
.game-foot button,
.fullscreen-button {
  font: inherit;
  border: none;
  border-radius: 6px;
  cursor: pointer;
}

.hud-actions button,
.top-head button,
#topForm button {
  background: #1a3a52;
  color: #e7f6ff;
  padding: 7px 14px;
}

.hud-actions button:hover,
.top-head button:hover,
#topForm button:hover { background: #24577a; }

#shop {
  position: relative;
  z-index: 1;
  flex: 1;
  overflow: auto;
  list-style: none;
  margin: 0;
  padding: 8px 12px 12px;
}

#game .shop-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin: 0 0 10px;
  padding: 12px 14px;
  border: 1px solid #1a3a52;
  border-radius: 8px;
  background: #e4eef6;
  opacity: 0.5;
  overflow: hidden;
}

#game .shop-item.is-hidden { display: none; }

#shopHint {
  list-style: none;
  margin: 8px 4px;
  text-align: center;
  font-size: 1rem;
}

#game .shop-body { flex: 1; min-width: 0; }

#game .shop-item.can-buy {
  opacity: 1;
  cursor: pointer;
  background: linear-gradient(180deg, #f7fcff 0%, #d4e8f4 100%);
}

#game .shop-item.can-buy:hover {
  background: linear-gradient(180deg, #ffffff 0%, #c5e4f6 100%);
}

#game .shop-lvl {
  flex: none;
  font-size: 1.8rem;
  line-height: 1;
}

#game .shop-lvl span { font-size: 0.9rem; }

#game .shop-item h3 {
  margin: 0 0 4px;
  font-size: 1.25rem;
  overflow-wrap: break-word;
}

#game .shop-desc {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.35;
  overflow-wrap: break-word;
}

#game .shop-cost { margin-top: 8px; font-weight: 700; }

.mini-key {
  display: inline-block;
  width: 34px;
  height: 12px;
  margin-inline-end: 6px;
  vertical-align: -1px;
  border: 2px solid #1a3a52;
  border-bottom-width: 4px;
  border-radius: 3px;
  background: linear-gradient(180deg, #f4fbff, #9ec3d8);
}

.game-foot {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  min-height: 36px;
  padding-block: 4px;
  padding-inline: 10px 130px;
  background: #1a3a52;
  color: #d7f1ff;
}

.game-foot button {
  background: transparent;
  color: #d7f1ff;
  padding: 4px 8px;
  text-decoration: underline;
}

.fullscreen-button {
  position: absolute;
  bottom: 10px;
  inset-inline-end: 10px;
  z-index: 3;
  max-width: 46%;
  background: linear-gradient(to right, #ff6b6b, #556270);
  color: #fff;
  padding: 10px 16px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.fullscreen-button:hover { background: linear-gradient(to right, #ff946b, #445370); }
.fullscreen-button:active { transform: scale(0.95); }

.top-panel {
  position: absolute;
  inset: 0;
  z-index: 6;
  overflow: auto;
  padding: 16px 16px 72px;
  background: #eef5fb;
}

.top-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.top-head h2 { margin: 0; font-size: 1.6rem; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.stat-card {
  padding: 8px 10px;
  border: 1px solid #1a3a52;
  border-radius: 8px;
  background: #f7fbfe;
}

.stat-card span { display: block; font-size: 0.75rem; }
.stat-card strong { font-size: 1.15rem; }

#topForm { display: flex; flex-wrap: wrap; gap: 8px; }

#topName {
  flex: 1;
  min-width: 140px;
  font: inherit;
  color: #1a3a52;
  padding: 8px 10px;
  border: 2px solid #1a3a52;
  border-radius: 6px;
  background: #fff;
}

.top-preview, .top-note { margin: 8px 0; font-size: 0.9rem; }
.top-msg { min-height: 1.2em; margin: 6px 0; font-weight: 700; }
.top-msg.ok { color: #1d6b45; }
.top-msg.bad { color: #8d3b2a; }
.top-table-wrap { overflow-x: auto; }

#topTable {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

#topTable th, #topTable td {
  padding: 6px 8px;
  text-align: start;
  border-bottom: 1px solid #b7c9d6;
  white-space: nowrap;
}

#topTable tr.is-you { background: #d7f0ff; }

.floater {
  position: absolute;
  z-index: 4;
  pointer-events: none;
  font-weight: 700;
  font-size: 1.3rem;
  animation: floatUp 0.8s ease-out forwards;
}

.rain-bit {
  position: absolute;
  z-index: 0;
  top: -16px;
  width: 18px;
  height: 8px;
  border: 1px solid #1a3a52;
  border-radius: 2px;
  background: linear-gradient(#f4fbff, #9ec3d8);
  pointer-events: none;
  animation: rainFall 2.8s linear forwards;
}

#game.shake { animation: gameShake 0.28s linear; }

@keyframes floatUp { to { transform: translateY(-78px); opacity: 0; } }
@keyframes rainFall { to { transform: translateY(780px) rotate(18deg); opacity: 0.15; } }
@keyframes gameShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

.guide {
  max-width: 820px;
  margin: 0 auto 12px;
  padding: 0 16px 8px;
  line-height: 1.7;
}

.guide h2 { margin: 1.4em 0 0.35em; font-size: 1.35rem; color: #1a3a52; }
.guide h3 { margin: 1em 0 0.2em; font-size: 1.05rem; }
.guide li { margin: 0.3em 0; }
.lede { font-size: 1.08rem; }

.text {
  max-width: 820px;
  margin: 20px auto;
  padding: 0 16px;
  line-height: 1.6;
}

.text h2 { margin: 1.2em 0 0.35em; font-size: 1.35rem; color: #1a3a52; }
.text h3 { margin: 1em 0 0.2em; font-size: 1.05rem; }

.text details {
  margin: 20px 0;
  border: 1px solid #ddd;
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.text summary {
  background: #f5f5f5;
  padding: 15px 20px;
  cursor: pointer;
  font-weight: bold;
  font-size: 16px;
  border-bottom: 1px solid #ddd;
}

.text summary:hover { background: #e8e8e8; }
.text details[open] summary { background: #e0e0e0; }
.text details > div { padding: 4px 20px 20px; }

.text table { width: 100%; border-collapse: collapse; margin: 8px 0 16px; }
.text th, .text td { padding: 8px 10px; border: 1px solid #ccd6de; text-align: start; }
.text th { background: #eef5fb; }

.site-footer {
  margin-top: 12px;
  padding: 18px 16px 8px;
  background: #f8f8f8;
  text-align: center;
}

.site-footer a { color: #1a3a52; }
.foot-links { justify-content: center; margin-bottom: 8px; }
.cookie-line, .copy { margin: 8px auto; max-width: 760px; }

.lang-label { margin: 18px 0 8px; font-weight: 700; }

.lang-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 14px;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 0 28px;
}

.lang-list a {
  color: #1a3a52;
  text-decoration: none;
  border-bottom: 1px solid transparent;
}

.lang-list a:hover,
.lang-list a[aria-current="page"] { border-bottom-color: currentColor; }
.lang-list a[aria-current="page"] { font-weight: 700; }

@media (max-width: 720px) {
  .content { min-height: 520px; height: 72vh; }
  #counter { font-size: 3.2rem; }
  .spacebar-key { letter-spacing: 0.28em; text-indent: 0.28em; }
  .brand { margin-inline-end: 0; }
}
