:root {
  --navy: #25324f;
  --navy-deep: #182139;
  --red: #e95845;
  --gold: #f6c453;
  --blue: #3b82b6;
  --mint: #51a887;
  --paper: #fffdf5;
  --cream: #f8f0df;
  --ink: #252a37;
  --line: rgba(37, 50, 79, .17);
  font-family: "Yu Gothic", "Hiragino Kaku Gothic ProN", system-ui, sans-serif;
  color: var(--ink);
  background: #e7edf4;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: #e7edf4; }
body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 8% 5%, rgba(246,196,83,.34), transparent 25rem),
    radial-gradient(circle at 95% 25%, rgba(59,130,182,.22), transparent 30rem),
    repeating-linear-gradient(90deg, transparent 0 39px, rgba(37,50,79,.025) 40px),
    linear-gradient(180deg, #edf3f8, #f8f0df 68%, #e3d5bc);
  touch-action: manipulation;
}

button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; }
button:focus-visible, a:focus-visible { outline: 4px solid var(--gold); outline-offset: 3px; }
.topbar { max-width: 1100px; margin: auto; padding: 14px clamp(14px,4vw,36px); display: flex; justify-content: space-between; align-items: center; }
.brand { color: var(--navy); text-decoration: none; font-weight: 950; letter-spacing: .09em; font-size: .82rem; }
.brand b { color: var(--red); }
.small-button { border: 1px solid var(--line); border-radius: 999px; padding: 9px 14px; background: rgba(255,255,255,.78); color: var(--navy); font-weight: 850; cursor: pointer; }

main { width: min(100% - 24px, 1020px); margin: 0 auto 42px; }
.hero { display: flex; align-items: end; justify-content: space-between; gap: 26px; padding: 22px 10px; }
.eyebrow { margin: 0 0 8px; color: var(--red); font-size: .78rem; font-weight: 950; letter-spacing: .12em; }
h1 { margin: 0; line-height: .96; font-size: clamp(2.35rem,8vw,5rem); letter-spacing: -.07em; color: var(--navy); }
h1 span { color: var(--red); }
.lead { max-width: 700px; margin: 15px 0 0; font-weight: 650; line-height: 1.75; }
.records { flex: 0 0 auto; display: grid; gap: 8px; }
.records span { padding: 10px 14px; border-radius: 12px; background: rgba(255,255,255,.82); box-shadow: 0 7px 22px rgba(37,50,79,.09); font-size: .8rem; font-weight: 750; }
.records strong { color: var(--red); font-size: 1.1rem; }

.learning-strip { padding: 15px; border: 1px solid var(--line); border-radius: 20px; background: rgba(255,255,255,.86); display: grid; grid-template-columns: repeat(3,1fr); gap: 9px; box-shadow: 0 14px 35px rgba(37,50,79,.08); }
.learning-strip div { padding: 11px 13px; border-radius: 13px; background: #edf5fa; }
.learning-strip b, .learning-strip span { display: block; }
.learning-strip b { color: var(--navy); }
.learning-strip span { margin-top: 3px; font-size: .76rem; }
.learning-strip p { grid-column: 1/-1; margin: 2px 4px 0; font-size: .8rem; line-height: 1.6; }

.game-shell { position: relative; margin-top: 18px; overflow: hidden; border: 1px solid var(--line); border-radius: 26px; background: rgba(248,240,223,.95); box-shadow: 0 24px 65px rgba(37,50,79,.17); }
.newsroom-scene { position: relative; min-height: 132px; overflow: hidden; display: flex; align-items: center; padding: 20px clamp(18px,4vw,42px); color: #fff; background: linear-gradient(125deg,#101a31 0%,#253b62 55%,#315b78 100%); isolation: isolate; }
.newsroom-scene::before { content: ""; position: absolute; inset: 0; z-index: -2; opacity: .26; background: repeating-linear-gradient(90deg,transparent 0 76px,rgba(255,255,255,.17) 77px 79px),repeating-linear-gradient(0deg,transparent 0 44px,rgba(255,255,255,.1) 45px 47px); }
.newsroom-scene::after { content: ""; position: absolute; inset: auto 0 0; height: 28px; z-index: -1; background: #6b4c38; border-top: 5px solid #422e24; box-shadow: 0 -7px 18px rgba(0,0,0,.25); }
.scene-copy { display: grid; gap: 3px; margin-right: auto; text-shadow: 0 2px 5px rgba(0,0,0,.35); }
.scene-copy span { width: max-content; padding: 3px 8px; border-radius: 5px; background: var(--red); font-size: .61rem; font-weight: 950; letter-spacing: .15em; }
.scene-copy b { font-family: Georgia,"Yu Mincho",serif; font-size: clamp(1.25rem,4vw,2rem); letter-spacing: .06em; }
.scene-copy small { color: #c9d9e7; font-weight: 800; }
.editor-character { position: relative; align-self: end; width: 92px; text-align: center; }
.editor-character span { display: block; font-size: 4.1rem; filter: drop-shadow(0 7px 4px rgba(0,0,0,.3)); transform-origin: bottom; animation: editor-bob 2.8s ease-in-out infinite; }
.editor-character i { position: absolute; z-index: 2; top: 15px; right: 2px; font-style: normal; font-size: 1.65rem; transform: rotate(-24deg); }
.editor-character em { position: relative; top: -8px; padding: 3px 8px; border-radius: 999px; color: var(--navy); background: var(--gold); font-size: .58rem; font-style: normal; font-weight: 950; }
.press-machine { position: relative; width: 112px; height: 86px; margin: 0 10px 3px 2px; padding: 10px; border: 4px solid #0e172a; border-radius: 12px 12px 4px 4px; background: #61718b; box-shadow: inset 0 0 0 3px #8290a5,0 8px 12px rgba(0,0,0,.3); text-align: center; }
.press-machine::after { content: ""; position: absolute; left: 12px; right: 12px; bottom: -18px; height: 22px; background: repeating-linear-gradient(90deg,#fff 0 9px,#d7dde6 10px 11px); clip-path: polygon(0 0,100% 0,94% 100%,6% 100%); }
.press-window { height: 42px; padding: 5px; overflow: hidden; border: 3px solid #202b40; border-radius: 5px; background: #eaf1f4; font-size: 1.55rem; }
.press-machine b { display: block; margin-top: 3px; font-size: .55rem; letter-spacing: .15em; }
.press-light { position: absolute; top: 6px; right: 7px; width: 8px; height: 8px; border-radius: 50%; background: #83e29a; box-shadow: 0 0 8px #83e29a; animation: press-blink 1.2s steps(2) infinite; }
.desk-lamp { position: absolute; right: 20%; bottom: 22px; width: 44px; height: 12px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 28px 12px rgba(246,196,83,.22); transform: rotate(-12deg); }
.flying-page { position: absolute; width: 27px; height: 35px; padding-top: 8px; color: var(--navy); background: #fffdf5; border: 1px solid #c9c0af; font: 950 .7rem Georgia,serif; text-align: center; box-shadow: 0 5px 9px rgba(0,0,0,.22); }
.page-one { right: 34%; top: 13px; transform: rotate(12deg); animation: paper-float 3s ease-in-out infinite; }
.page-two { right: 22%; top: 9px; transform: rotate(-9deg); animation: paper-float 3.4s .5s ease-in-out infinite reverse; }
@keyframes editor-bob { 0%,100% { transform: rotate(-2deg) translateY(0); } 50% { transform: rotate(2deg) translateY(-4px); } }
@keyframes press-blink { 50% { opacity: .35; } }
@keyframes paper-float { 0%,100% { translate: 0 0; } 50% { translate: 0 7px; } }
.hud { display: grid; grid-template-columns: repeat(4,1fr); color: #fff; background: var(--navy); }
.hud div { padding: 13px 9px; text-align: center; border-right: 1px solid rgba(255,255,255,.14); }
.hud div:last-child { border: 0; }
.hud small { display: block; color: #bfc9dc; font-size: .63rem; font-weight: 900; letter-spacing: .09em; }
.hud b { display: block; margin-top: 3px; font-size: 1rem; }
.issue-progress { display: grid; grid-template-columns: repeat(10,1fr); gap: 5px; padding: 9px 15px 0; }
.issue-dot { position: relative; height: 8px; overflow: hidden; border-radius: 999px; background: #d8d4ca; box-shadow: inset 0 1px 2px rgba(0,0,0,.12); }
.issue-dot.done { background: var(--mint); }
.issue-dot.current { background: var(--gold); box-shadow: 0 0 0 3px rgba(246,196,83,.25); }

.event-board { margin: 15px; padding: 13px 16px; display: flex; align-items: center; gap: 14px; border-radius: 17px; color: var(--navy); background: linear-gradient(135deg,#fff6cf,#fffdf5); border: 1px solid rgba(190,140,24,.25); }
#eventIcon { font-size: 2.7rem; filter: drop-shadow(0 5px 6px rgba(37,50,79,.14)); }
.event-board small { font-size: .66rem; font-weight: 950; color: #84661f; }
.event-board h2 { margin: 1px 0; font-size: 1.08rem; }
.event-board p { margin: 0; font-size: .76rem; line-height: 1.45; }

.desk-layout { display: grid; grid-template-columns: minmax(0,1.25fr) minmax(290px,.75fr); gap: 14px; padding: 0 15px 15px; }
.manuscript { position: relative; overflow: hidden; min-width: 0; padding: 18px; border: 1px solid #d9cfb9; border-radius: 18px; background: var(--paper); box-shadow: 0 9px 22px rgba(75,58,35,.09); }
.manuscript::before { content: "KOTOBA TIMES"; position: absolute; top: 7px; right: -23px; transform: rotate(35deg); padding: 3px 27px; background: var(--red); color: #fff; font-size: .54rem; font-weight: 950; letter-spacing: .08em; }
.paper-heading { display: flex; justify-content: space-between; align-items: start; gap: 10px; padding-bottom: 11px; border-bottom: 4px double var(--navy); }
.paper-heading small { color: var(--red); font-weight: 950; }
.paper-heading h2 { margin: 3px 0 0; padding-right: 20px; line-height: 1.25; font-size: clamp(1.2rem,4vw,1.75rem); }
#audienceBadge { flex: 0 0 auto; margin-top: 22px; padding: 5px 8px; border-radius: 999px; background: #e8eef7; font-size: .65rem; font-weight: 850; }
.mission { margin: 12px 0; padding: 9px 11px; border-left: 4px solid var(--gold); background: #fff8dc; font-size: .78rem; font-weight: 750; line-height: 1.5; }
.draft-box { min-height: 145px; padding: 13px; border-radius: 12px; background: #f4f0e8; }
.draft-label { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.draft-label span { color: #766c5c; font-size: .63rem; font-weight: 950; }
.draft-label b { padding: 3px 8px; border-radius: 999px; color: #6d6048; background: #e6dfd0; font-size: .59rem; }
.draft-label b.changed { color: #fff; background: var(--red); animation: status-pop .45s ease; }
.draft-box p { margin: 6px 0 8px; line-height: 1.7; font-family: "Yu Mincho","Hiragino Mincho ProN",serif; font-weight: 700; }
.draft-box p.rewriting { animation: rewrite-flash .55s ease; }
.manuscript.edit-pulse { animation: paper-pulse .46s ease; }
@keyframes rewrite-flash { 0% { opacity: .2; transform: translateY(5px); background: rgba(246,196,83,.45); } 100% { opacity: 1; transform: none; background: transparent; } }
@keyframes paper-pulse { 40% { transform: rotate(-.25deg) scale(1.006); box-shadow: 0 13px 30px rgba(233,88,69,.18); } }
@keyframes status-pop { 50% { transform: scale(1.1); } }
.draft-box ul { margin: 0; padding-left: 1.15rem; color: #45516d; font-size: .73rem; line-height: 1.55; }
.meter-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; margin-top: 13px; }
.meter { padding: 9px; border: 1px solid var(--line); border-radius: 11px; background: #fff; }
.meter-head { display: flex; justify-content: space-between; gap: 5px; font-size: .7rem; font-weight: 900; }
.meter-head b.ready { color: var(--mint); }
.track { height: 7px; margin-top: 7px; overflow: hidden; border-radius: 999px; background: #dfe3ea; }
.track span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg,var(--blue),var(--mint)); transition: width .35s ease; }
.word-meter { margin-top: 11px; }
.word-meter > div:first-child { display: flex; justify-content: space-between; font-size: .72rem; font-weight: 850; }
.word-meter .track span { background: var(--gold); }
.word-meter.over .track span { background: var(--red); }
.word-meter.over b { color: var(--red); }

.control-panel { display: flex; flex-direction: column; gap: 10px; }
.panel-section { padding: 14px; border: 1px solid var(--line); border-radius: 16px; background: rgba(255,255,255,.8); }
.panel-section h2 { margin: 0; color: var(--navy); font-size: .9rem; }
.panel-section > p { margin: 5px 0 11px; color: #5a6172; font-size: .68rem; line-height: 1.45; }
.policy-buttons { display: grid; grid-template-columns: repeat(3,1fr); gap: 6px; }
.policy-button { min-height: 58px; padding: 7px 4px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--navy); font-size: .7rem; font-weight: 900; cursor: pointer; }
.policy-button span { display: block; font-size: 1.15rem; }
.policy-button.selected { border-color: var(--red); background: #fff0ed; box-shadow: inset 0 0 0 1px var(--red); }
.policy-button:disabled:not(.selected) { opacity: .4; }
.edit-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.edit-button { min-height: 61px; padding: 7px; border: 1px solid var(--line); border-radius: 11px; background: #fff; color: var(--ink); text-align: left; font-size: .72rem; font-weight: 900; cursor: pointer; }
.edit-button span { margin-right: 4px; font-size: 1.05rem; }
.edit-button small { display: block; margin-top: 3px; color: #657086; font-size: .59rem; font-weight: 700; }
.edit-button:disabled { opacity: .4; cursor: not-allowed; }
.edit-button:not(:disabled):active { transform: scale(.97); }
.primary-button { width: 100%; border: 0; border-radius: 13px; padding: 14px 16px; color: #fff; background: linear-gradient(135deg,var(--red),#c93e35); font-weight: 950; box-shadow: 0 7px 0 #8f2e2a; cursor: pointer; }
.primary-button:active { transform: translateY(3px); box-shadow: 0 4px 0 #8f2e2a; }
.primary-button:disabled { opacity: .42; box-shadow: none; cursor: not-allowed; }
.newsroom-log { margin: 0 15px 18px; padding: 12px 15px; border-left: 4px solid var(--blue); border-radius: 0 12px 12px 0; background: rgba(255,255,255,.72); }
.newsroom-log h2 { margin: 0 0 5px; font-size: .82rem; }
.newsroom-log ul { margin: 0; padding-left: 1.15rem; font-size: .72rem; line-height: 1.55; }

.overlay { position: absolute; z-index: 10; inset: 0; min-height: 100%; padding: 22px; display: grid; place-items: center; background: rgba(24,33,57,.86); backdrop-filter: blur(5px); }
.overlay[hidden] { display: none; }
.overlay-card { width: min(100%,620px); max-height: calc(100vh - 44px); overflow-y: auto; padding: clamp(20px,5vw,32px); border-radius: 22px; background: var(--paper); text-align: center; box-shadow: 0 25px 75px rgba(0,0,0,.27); }
.overlay-icon { font-size: 3.1rem; }
.overlay-card h2 { margin: 8px 0; color: var(--navy); font-size: clamp(1.45rem,5vw,2.2rem); }
.overlay-card > p { margin: 0; line-height: 1.7; font-size: .88rem; }
.result-details { margin: 14px 0 2px; display: grid; grid-template-columns: repeat(3,1fr); gap: 7px; }
.result-details div { padding: 10px 5px; border-radius: 11px; background: #eaf0f7; }
.result-details small { display: block; color: #657086; font-size: .59rem; }
.result-details b { display: block; margin-top: 2px; color: var(--navy); }
#rankingWrap { margin-top: 18px; text-align: left; }
footer { padding: 0 16px 30px; color: #70788a; text-align: center; font-size: .66rem; font-weight: 900; letter-spacing: .18em; }

@media (max-width: 780px) {
  .hero { align-items: stretch; flex-direction: column; gap: 14px; }
  .records { grid-template-columns: 1fr 1fr; }
  .desk-layout { grid-template-columns: 1fr; }
  .control-panel { display: grid; grid-template-columns: 1fr 1fr; }
  .control-panel > .primary-button { grid-column: 1/-1; }
}

@media (max-width: 520px) {
  main { width: min(100% - 14px,1020px); }
  .topbar { padding-inline: 10px; }
  .brand { font-size: .68rem; }
  .small-button { padding: 8px 10px; font-size: .73rem; }
  h1 { font-size: clamp(2.15rem,13vw,3.4rem); }
  .lead { font-size: .86rem; }
  .learning-strip { grid-template-columns: 1fr; padding: 10px; }
  .learning-strip p { grid-column: auto; }
  .hud { grid-template-columns: 1fr 1fr; }
  .newsroom-scene { min-height: 108px; padding: 14px; }
  .scene-copy b { font-size: 1.05rem; }
  .scene-copy small { font-size: .61rem; }
  .editor-character { width: 68px; }
  .editor-character span { font-size: 3.1rem; }
  .editor-character i { font-size: 1.2rem; }
  .press-machine { width: 76px; height: 65px; margin-right: 0; padding: 6px; }
  .press-window { height: 30px; padding: 1px; font-size: 1.15rem; }
  .desk-lamp,.flying-page { display: none; }
  .hud div:nth-child(2) { border-right: 0; }
  .hud div:nth-child(-n+2) { border-bottom: 1px solid rgba(255,255,255,.14); }
  .event-board { margin: 10px; }
  .desk-layout { padding: 0 10px 10px; }
  .manuscript { padding: 13px; }
  .paper-heading { flex-direction: column; }
  #audienceBadge { margin-top: 0; }
  .meter-grid { grid-template-columns: 1fr; }
  .control-panel { display: flex; }
  .newsroom-log { margin-inline: 10px; }
  .overlay { padding: 9px; }
  .overlay-card { max-height: calc(100vh - 18px); }
}

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