/* 旧版（Next.js + Tailwind + framer-motion）の見た目を素の CSS で再現 */
@import url('https://fonts.googleapis.com/css2?family=Noto+Serif+JP:wght@400;500;600;700&family=Shippori+Mincho:wght@400;600;700&family=Yuji+Mai&display=swap');
:root {
  --serif: "Noto Serif JP", "Yu Mincho", "Hiragino Mincho ProN", serif;
  --shippori: "Shippori Mincho", "Noto Serif JP", "Yu Mincho", serif;
  --brush: "Yuji Mai", "HGS行書体", "HG行書体", "AR行書体M", cursive;
  --gold: #d4af37;
  --ink: #1a1a2e;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--serif); color: var(--ink); }
button { font-family: inherit; }
.hidden { display: none !important; }

/* ---- 共通: 架空であることの表示 ---- */
.fiction-note { font: 500 0.72rem/1.6 var(--serif); color: rgba(26,26,46,0.75); }

/* ---- landing ---- */
#landing { height: 100vh; display: flex; align-items: center; justify-content: center; position: relative;
  background: url(/static/assets/landing-bg.jpg) center / cover no-repeat; }
#landing::before { content: ''; position: absolute; inset: 0; z-index: 1;
  background: linear-gradient(180deg, rgba(255,255,255,0.1) 0%, rgba(255,255,255,0.2) 50%, rgba(255,255,255,0.3) 100%); }
.landing-inner { position: relative; z-index: 2; max-width: 1000px; width: 90%; text-align: center; padding: 2rem; display: flex; flex-direction: column; align-items: center; }
.title-logo { width: 100%; max-width: 1000px; height: auto; margin: 0 auto 2.5rem; display: block; filter: drop-shadow(0 4px 12px rgba(0,0,0,0.4)); opacity: 0; transform: translateY(-30px); transition: opacity 1s ease-out, transform 1s ease-out; }
.title-fallback { font-family: var(--brush); font-size: clamp(3rem, 10vw, 9rem); font-weight: 900; margin-bottom: 3rem; letter-spacing: 0.2em; line-height: 1.2; text-shadow: 0 4px 12px rgba(255,255,255,0.8), 0 0 30px rgba(255,255,255,0.6); }
.subtitle { font-size: 0.95rem; line-height: 1.8; letter-spacing: 0.05em; font-weight: 500; margin: 0 auto 2.5rem; max-width: 700px; text-shadow: 0 2px 4px rgba(255,255,255,0.8); opacity: 0; transform: translateY(-20px); transition: opacity .8s ease-out, transform .8s ease-out; }
.start-btn { background: linear-gradient(180deg, #1a1a2e 0%, #0f1419 100%); border: 4px solid #1a1a2e; padding: 1.8rem 4.5rem; font-size: 1.7rem; font-weight: bold; color: #fff; cursor: pointer; box-shadow: 0 8px 20px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.1); border-radius: 12px; letter-spacing: 0.12em; margin-top: 1rem; opacity: 0; transform: scale(0.8); transition: opacity .5s ease-out, transform .5s ease-out, box-shadow .2s, background .2s; }
.start-btn:hover { transform: translateY(-3px) scale(1.02); box-shadow: 0 12px 28px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.2); background: linear-gradient(180deg, #2a2a3e 0%, #1a1a2e 100%); }
.archive-btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.65rem; margin-top: 1.2rem; padding: 0.8rem 1.25rem; min-height: 3rem; border: 2px solid rgba(26,26,46,0.8); border-radius: 999px; background: rgba(255,255,255,0.94); color: #1a1a2e; font-size: clamp(0.95rem,2.5vw,1.12rem); font-weight: 700; text-decoration: none; box-shadow: 0 5px 18px rgba(0,0,0,0.2); transition: transform .2s, background .2s, box-shadow .2s; }
.archive-btn:hover, .archive-btn:focus-visible { background: #fff7dc; transform: translateY(-2px); box-shadow: 0 7px 22px rgba(0,0,0,0.25); }
.shown { opacity: 1 !important; transform: none !important; }
.corner-right { position: absolute; right: 2rem; bottom: 2rem; z-index: 3; display: flex; gap: 0.5rem; align-items: center; }
.test-btn { background: rgba(255,255,255,0.6); border: 1px solid rgba(26,26,46,0.2); padding: 0.4rem 0.8rem; font-size: 0.7rem; color: rgba(26,26,46,0.6); cursor: pointer; border-radius: 4px; opacity: 0; transition: all .2s; }
.test-btn.shown { opacity: 0.5 !important; }
.test-btn:hover { opacity: 1 !important; background: rgba(255,255,255,0.9); color: #1a1a2e; }
.test-btn:disabled { cursor: not-allowed; opacity: 0.3 !important; }
.intake-notice { width: min(100%, 640px); margin: 0 auto 1rem; padding: 0.8rem 1rem; border: 2px solid #7f1d1d; border-radius: 8px; background: #fff4ed; color: #7f1d1d; font: 500 0.95rem/1.6 var(--serif); box-shadow: 0 3px 12px rgba(0,0,0,0.15); }
.intake-notice strong { display: block; font-size: 1.15rem; }
.intake-notice .intake-message { display: block; white-space: pre-wrap; }
.usage .intake-notice { margin: 0 0 0.8rem; }
.gpu-busy { width: min(100%, 660px); margin: 0 auto 1rem; padding: 0.9rem 1.1rem; display: flex; gap: 1rem; align-items: center; justify-content: center; border: 3px solid #d4af37; border-radius: 10px; background: rgba(15,20,25,0.9); color: #f0e6d2; box-shadow: 0 8px 24px rgba(0,0,0,0.28); }
.gpu-busy img { width: 4.5rem; height: 4.5rem; object-fit: contain; flex: none; background: #fff; border-radius: 50%; padding: 0.3rem; }
.gpu-busy strong { display: block; color: #f4d03f; font-family: var(--brush); font-size: clamp(1.8rem, 5vw, 3rem); line-height: 1.1; letter-spacing: 0.08em; text-shadow: 0 2px 8px rgba(0,0,0,0.65); }
.gpu-busy span { display: block; margin-top: 0.2rem; font-size: 0.88rem; font-weight: 700; }
.landing-queue { margin: -0.7rem auto 0.8rem; padding: 0.55rem 1rem; border-radius: 999px; background: rgba(255,255,255,0.9); border: 1px solid rgba(26,26,46,0.18); color: #1a1a2e; font-size: 0.86rem; font-weight: 700; box-shadow: 0 2px 8px rgba(0,0,0,0.12); }
.landing-note { position: absolute; left: 50%; bottom: 0.75rem; transform: translateX(-50%); z-index: 3; width: min(92vw, 720px); text-align: center; padding: 0.45rem 0.7rem; background: rgba(255,255,255,0.88); border-radius: 6px; color: #1a1a2e; font-size: 0.8rem; }
.landing-note a { color: #123b72; text-decoration: underline; }

/* ---- map ---- */
#map-stage { height: 100vh; display: flex; flex-direction: column; background: linear-gradient(180deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%); }
.map-header { background: linear-gradient(180deg, #0f1419 0%, #1a2332 100%); border-bottom: 4px solid var(--gold); padding: 1.1rem 2rem; box-shadow: 0 4px 8px rgba(0,0,0,0.5); display: flex; justify-content: space-between; align-items: center; }
.back-btn { background: rgba(212,175,55,0.2); border: 2px solid rgba(212,175,55,0.5); padding: 0.5rem 1rem; font-size: 0.9rem; color: var(--gold); cursor: pointer; border-radius: 4px; }
.map-header h2 { font-size: 1.2rem; color: var(--gold); letter-spacing: 0.1em; margin: 0; }
.map-wrap { flex: 1; position: relative; }
#map { position: absolute; inset: 0; }
.gold-corner { position: absolute; width: 100px; height: 100px; pointer-events: none; z-index: 500; }
.gc-tl { top: 0; left: 0; border-top: 4px solid var(--gold); border-left: 4px solid var(--gold); }
.gc-tr { top: 0; right: 0; border-top: 4px solid var(--gold); border-right: 4px solid var(--gold); }
.gc-bl { bottom: 0; left: 0; border-bottom: 4px solid var(--gold); border-left: 4px solid var(--gold); }
.gc-br { bottom: 0; right: 0; border-bottom: 4px solid var(--gold); border-right: 4px solid var(--gold); }
.usage { position: absolute; bottom: 1.5rem; left: 1.5rem; z-index: 600; background: linear-gradient(135deg, #0f1419 0%, #1a2332 100%); padding: 1.3rem 1.5rem; border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,0.6); max-width: 450px; border: 3px solid var(--gold); color: #f0e6d2; }
.usage-title { font-size: 1.1rem; font-weight: bold; color: var(--gold); letter-spacing: 0.1em; border-bottom: 2px solid var(--gold); padding-bottom: 0.6rem; margin: 0 0 0.6rem; }
.usage p { font-size: 0.92rem; line-height: 1.8; margin: 0; }
.coord-row { display: flex; gap: 0.4rem; margin-top: 0.8rem; flex-wrap: wrap; align-items: center; }
.coord-row input { width: 9.5rem; padding: 0.35rem 0.5rem; border-radius: 4px; border: 1px solid rgba(212,175,55,0.6); background: #0f1419; color: #f0e6d2; font: 0.85rem monospace; }
.coord-row label { font-size: 0.8rem; color: var(--gold); }
.open-btn { margin-top: 0.8rem; width: 100%; background: linear-gradient(180deg, #d4af37 0%, #a8862a 100%); color: #1a1a2e; border: 2px solid #f4d03f; padding: 0.7rem 1rem; font-size: 1.05rem; font-weight: bold; border-radius: 6px; cursor: pointer; letter-spacing: 0.1em; }
.open-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.queue-line { margin-top: 0.5rem; font-size: 0.8rem; color: rgba(240,230,210,0.8); }
.error-box { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); background: #8b0000; color: #fff; padding: 1.5rem 2rem; border-radius: 8px; box-shadow: 0 8px 16px rgba(0,0,0,0.5); border: 3px solid var(--gold); font-size: 1.05rem; z-index: 1000; max-width: 90vw; }
.leaflet-container { font-family: var(--serif); }

/* ---- loading（旧 LoadingScreen.tsx） ---- */
#loading { position: fixed; inset: 0; overflow-y: auto; background: linear-gradient(180deg, #0f1419 0%, #1a2332 50%, #0f1419 100%); display: flex; flex-direction: column; align-items: center; padding: clamp(1.5rem, 6vh, 4rem) 0 2rem; z-index: 50; color: #f0e6d2; }
.loading-inner { text-align: center; padding: 0 1.5rem; max-width: 800px; width: 100%; }
.hole { margin: 0 auto 1.2rem; width: min(11rem, 27vh); height: min(11rem, 27vh); background: #fff; border-radius: 50%; display: flex; align-items: center; justify-content: center; box-shadow: 0 0 32px rgba(0,0,0,0.25), 0 8px 24px rgba(0,0,0,0.2); border: 4px solid rgba(0,0,0,0.08); overflow: hidden; }
.worker { width: 9rem; height: auto; max-height: 10.5rem; object-fit: contain; display: block; transform-origin: 50% 28%; will-change: transform; }
.loading-title { font-family: var(--brush); font-size: 3rem; font-weight: bold; color: var(--gold); margin: 0 0 0.8rem; text-shadow: 0 4px 8px rgba(0,0,0,0.8); letter-spacing: 0.15em; animation: fadeDown .5s ease-out; }
@keyframes fadeDown { from { opacity: 0; transform: translateY(-20px) } to { opacity: 1; transform: none } }
.time-estimate { margin: 0 auto 1.1rem; padding: 0.6rem 1rem; width: fit-content; max-width: 100%; border-radius: 999px; background: rgba(255,255,255,0.1); color: #fff0bb; font-size: 0.95rem; font-weight: 700; }
.drill-toggle { min-height: 2.6rem; margin: 0.2rem auto 0; padding: 0.45rem 1rem; border: 1px solid rgba(244,208,63,0.65); border-radius: 999px; background: rgba(212,175,55,0.14); color: #fff0bb; font: 700 0.85rem var(--serif); cursor: pointer; }
.drill-toggle:hover, .drill-toggle:focus-visible { background: rgba(212,175,55,0.3); }
.sound-credit { margin: 0.35rem 0 0; font-size: 0.65rem; color: rgba(240,230,210,0.65); }
.sound-credit a { color: inherit; }
.queue-box { margin: 0 auto 1rem; padding: 0.6rem 1rem; max-width: 520px; border: 2px dashed rgba(212,175,55,0.5); border-radius: 8px; color: #f4d03f; font-weight: bold; letter-spacing: 0.05em; }
.msg-box { min-height: 3.2rem; margin-bottom: 0.8rem; background: rgba(212,175,55,0.1); border: 2px solid rgba(212,175,55,0.3); border-radius: 8px; display: flex; align-items: center; justify-content: center; padding: 0.65rem 1rem; overflow: hidden; }
.msg { font-size: 1.25rem; letter-spacing: 0.05em; margin: 0; transition: opacity .5s, transform .5s; }
.msg.out { opacity: 0; transform: translateY(-20px); }
.msg.in { opacity: 0; transform: translateY(20px); }
.bar-wrap { width: 100%; max-width: 400px; margin: 0 auto; }
.bar { width: 100%; background: rgba(15,20,25,0.8); border-radius: 8px; height: 1.5rem; overflow: hidden; box-shadow: inset 0 2px 8px rgba(0,0,0,0.5); border: 2px solid #8b7355; }
.bar-fill { height: 100%; width: 0; background: linear-gradient(90deg, #d4af37 0%, #f4d03f 50%, #d4af37 100%); box-shadow: 0 0 20px rgba(212,175,55,0.5); transition: width .5s; }
.bar-label { color: var(--gold); margin-top: 0.5rem; font-size: 1rem; font-weight: bold; letter-spacing: 0.1em; min-height: 1.5em; }
.dots { display: flex; justify-content: center; margin-top: 1rem; gap: 0.5rem; }
.dots span { width: 0.75rem; height: 0.75rem; background: var(--gold); border-radius: 50%; box-shadow: 0 0 10px rgba(212,175,55,0.5); animation: dot 1.5s infinite; }
.dots span:nth-child(2) { animation-delay: .2s } .dots span:nth-child(3) { animation-delay: .4s }
@keyframes dot { 0%, 100% { transform: scale(1); opacity: .5 } 50% { transform: scale(1.5); opacity: 1 } }
.peek-link { display: inline-block; margin-top: 1.5rem; color: #f4d03f; font-size: 0.95rem; }

/* ---- Congratulations ---- */
#congrats { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; background: radial-gradient(ellipse at center, rgba(0,0,0,0.5) 0%, rgba(0,0,0,0.85) 100%); pointer-events: none; animation: fadeIn .2s; }
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
#congrats span { position: relative; z-index: 2; font-size: clamp(2.3rem, 10vw, 5rem); font-weight: 900; letter-spacing: 0.08em; font-family: var(--brush), system-ui, sans-serif; background: linear-gradient(180deg, #fff 0%, #ffd700 40%, #ff8c00 100%); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; filter: drop-shadow(0 0 20px rgba(255,215,0,0.8)); animation: pop .5s cubic-bezier(.34,1.56,.64,1), glow .8s infinite alternate; }
@keyframes pop { from { transform: scale(.3); opacity: 0 } to { transform: scale(1); opacity: 1 } }
@keyframes glow { from { filter: drop-shadow(0 0 20px rgba(255,215,0,.8)) } to { filter: drop-shadow(0 0 40px rgba(255,140,0,1)) } }
.confetti-bit { position: fixed; z-index: 1; width: 0.55rem; height: 0.95rem; border-radius: 0.12rem; animation: confettiFall 1.8s ease-out forwards; transform: translate3d(0,0,0) rotate(0); }
@keyframes confettiFall { to { transform: translate3d(var(--x), var(--y), 0) rotate(var(--r)); opacity: 0; } }

/* ---- archive（旧 app/archive/page.tsx） ---- */
.archive { min-height: 100vh; background: #e5e2dc; padding: 2rem 1rem; }
.archive-inner { max-width: 960px; margin: 0 auto; }
.archive h1 { font-size: clamp(1.75rem, 4vw, 2.5rem); font-weight: 600; font-family: var(--shippori); margin: 0 0 0.5rem; }
.archive .lead { color: #5c5c5c; font-size: 0.95rem; margin: 0 0 1.5rem; }
.archive .to-create { display: inline-block; margin-bottom: 1.5rem; font-size: 0.9rem; color: #4a5568; }
.archive-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.archive-card { display: flex; gap: 0.8rem; align-items: center; padding: 0.9rem; background: #faf9f7; border-radius: 8px; border: 1px solid #d4cfc7; text-decoration: none; color: inherit; }
.archive-card img, .archive-card .noimg { width: 112px; height: 74px; border-radius: 6px; border: 2px solid #e5e7eb; object-fit: cover; flex: none; background: #e5e7eb; display: flex; align-items: center; justify-content: center; font-size: 1.5rem; }
.archive-card:hover { transform: translateY(-2px); box-shadow: 0 7px 18px rgba(0,0,0,0.12); border-color: #b99b42; }
.archive-card .n { font-weight: 600; font-size: 1.05rem; font-family: var(--shippori); }
.archive-card .a { font-size: 0.78rem; color: #6b7280; }
.archive-empty { padding: 2rem; text-align: center; color: #5c5c5c; background: #faf9f7; border-radius: 8px; border: 1px dashed #c9c4bc; }

/* 接続が確認できるまでは受付を閉じ、準備中として表示する。 */
body.school-offline #landing { filter: grayscale(1); }
body.school-offline .intake-notice { border-color: #555; color: #252525; background: #f4f4f4; }
.start-btn:disabled, .open-btn:disabled { cursor: not-allowed; opacity: .65 !important; box-shadow: none; }
.start-btn:disabled:hover { transform: none; }
@media (max-height: 800px) {
  #landing { overflow-y: auto; }
  .landing-inner { padding-bottom: 100px; }
  body.school-offline .title-logo { max-height: 30vh; width: auto; max-width: 90vw; object-fit: contain; }
}
