:root {
  color-scheme: dark;
  --portal-bg: #0b1020;
  --portal-panel: rgba(17, 24, 39, .78);
  --portal-line: rgba(255,255,255,.12);
  --portal-text: #eef4ff;
  --portal-muted: #aebbd0;
  --portal-blue: #4f8cff;
  --portal-green: #36d399;
  --portal-pink: #ff6fb1;
  --portal-gold: #f7c948;
}

* { box-sizing: border-box; }

body.portal-home {
  margin: 0;
  min-height: 100dvh;
  font-family: Inter, system-ui, "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;
  color: var(--portal-text);
  background:
    radial-gradient(900px 520px at 14% 8%, rgba(79,140,255,.28), transparent 62%),
    radial-gradient(820px 500px at 88% 18%, rgba(255,111,177,.20), transparent 58%),
    linear-gradient(135deg, #0b1020 0%, #121a2b 46%, #13221f 100%);
}

.portal-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 34px;
}

.portal-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 22px;
  align-items: end;
  padding: 18px 0 26px;
}

.portal-title h1 {
  margin: 0;
  font-size: clamp(34px, 7vw, 76px);
  line-height: .92;
  letter-spacing: 0;
}

.portal-title {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  flex-wrap: wrap;
  min-width: 0;
}

.portal-title-hint {
  color: var(--portal-muted);
  font-size: clamp(11px, 1.75vw, 19px);
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
  padding-bottom: 3px;
}

.portal-title p {
  max-width: 720px;
  margin: 18px 0 0;
  color: var(--portal-muted);
  font-size: 16px;
  line-height: 1.6;
}

.portal-actions {
  display: grid;
  grid-template-columns: 64px auto;
  gap: 10px;
  align-items: stretch;
}

.portal-qr-launch {
  min-height: 100%;
  padding: 0;
  font-size: 15px;
  letter-spacing: 0;
  background: linear-gradient(160deg, rgba(79,140,255,.34), rgba(54,211,153,.25));
  box-shadow: 0 18px 50px rgba(0,0,0,.22);
}

.portal-nick {
  border: 1px solid var(--portal-line);
  background: var(--portal-panel);
  backdrop-filter: blur(18px);
  border-radius: 8px;
  padding: 6px;
  box-shadow: 0 20px 70px rgba(0,0,0,.26);
}

.portal-nick label {
  display: none;
  color: var(--portal-muted);
  font-size: 13px;
  margin-bottom: 8px;
}

.portal-nick-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.portal-input, .portal-textarea {
  width: 100%;
  border: 1px solid var(--portal-line);
  border-radius: 8px;
  background: rgba(5, 10, 22, .74);
  color: var(--portal-text);
  outline: none;
  padding: 11px 12px;
  font: inherit;
}

.portal-nick .portal-input {
  width: 120px;
  padding: 8px 10px;
}

.portal-nick .portal-btn {
  min-height: 38px;
  padding: 0 12px;
}

.portal-input:focus, .portal-textarea:focus {
  border-color: rgba(79,140,255,.8);
  box-shadow: 0 0 0 3px rgba(79,140,255,.18);
}

.portal-btn {
  border: 1px solid var(--portal-line);
  border-radius: 8px;
  background: rgba(255,255,255,.08);
  color: var(--portal-text);
  min-height: 42px;
  padding: 0 14px;
  cursor: pointer;
  font-weight: 800;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
}

.portal-btn.primary {
  border-color: transparent;
  background: linear-gradient(90deg, var(--portal-blue), var(--portal-green));
  color: #06101f;
}

.portal-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.portal-grid-ad {
  min-width: 0;
  height: 310px;
  margin: 0;
  border: 1px dashed rgba(255,255,255,.20);
  border-radius: 8px;
  background: rgba(0,0,0,.18);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 24px 6px 8px;
  position: relative;
}

.portal-grid-ad-label {
  position: absolute;
  top: 7px;
  left: 0;
  width: 100%;
  color: var(--portal-muted);
  font-size: 10px;
  line-height: 1;
  letter-spacing: .08em;
  text-align: center;
}

.portal-grid-ad .adsbygoogle {
  width: 100%;
}

.game-tile {
  position: relative;
  min-height: 310px;
  border: 1px solid var(--portal-line);
  border-radius: 8px;
  overflow: hidden;
  color: var(--portal-text);
  text-decoration: none;
  background: rgba(255,255,255,.07);
  box-shadow: 0 20px 60px rgba(0,0,0,.22);
  transform: translateY(0);
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
  display: flex;
  flex-direction: column;
}

.game-ribbon {
  --ribbon-color: #f7c948;
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 4;
  min-width: 92px;
  min-height: 28px;
  padding: 0 12px 0 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #1c2233;
  background: linear-gradient(180deg, rgba(255,255,255,.26), rgba(255,255,255,0)) var(--ribbon-color);
  border: 1px solid rgba(255,255,255,.44);
  border-right: 0;
  border-radius: 7px 0 0 7px;
  box-shadow: 0 10px 24px rgba(0,0,0,.28);
  font: 900 12px/1 Inter, system-ui, "Malgun Gothic", sans-serif;
  letter-spacing: 0;
  white-space: nowrap;
}

.game-ribbon::after {
  content: "";
  position: absolute;
  top: -1px;
  right: -13px;
  width: 14px;
  height: calc(100% + 2px);
  background: var(--ribbon-color);
  clip-path: polygon(0 0, 100% 0, 48% 50%, 100% 100%, 0 100%);
  filter: brightness(.94);
}

.game-ribbon.rank-1 { --ribbon-color: #ffd54a; }
.game-ribbon.rank-2 { --ribbon-color: #cbd5e1; color: #142033; }
.game-ribbon.rank-3 { --ribbon-color: #f2a65f; color: #261604; }

.game-tile.top-ranked .tile-media::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0,0,0,.30), transparent 46%);
  pointer-events: none;
}

.game-tile:hover {
  transform: translateY(-4px);
  border-color: rgba(255,255,255,.32);
  box-shadow: 0 26px 80px rgba(0,0,0,.34);
}

.tile-media {
  height: 154px;
  background: linear-gradient(135deg, rgba(79,140,255,.30), rgba(255,111,177,.22));
  position: relative;
  overflow: hidden;
}

.tile-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.bumperball-media {
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 50% 50%, rgba(74, 161, 255, .28), rgba(5, 10, 22, .92));
}

.bumperball-media img {
  width: 88%;
  height: 88%;
  object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 10px 26px rgba(0, 0, 0, .25);
}

.rocket-media .rocket-sky {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.rocket-media .rocket-ship {
  position: absolute;
  z-index: 1;
  left: 50%;
  top: 50%;
  width: 190px;
  height: 92px;
  object-fit: contain;
  transform: translate(-50%, -45%);
  filter: drop-shadow(0 10px 16px rgba(80, 230, 255, .38));
}

.rocket-tile:hover .rocket-ship {
  transform: translate(-50%, -50%);
  transition: transform .22s ease;
}

.tile-media.no-image {
  display: grid;
  place-items: center;
  font-size: 42px;
  font-weight: 1000;
}

.tile-body {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}

.tile-kicker {
  color: var(--portal-muted);
  font-size: 12px;
}

.tile-body h2 {
  margin: 0;
  font-size: 22px;
  line-height: 1.15;
}

.tile-body p {
  margin: 0;
  color: var(--portal-muted);
  line-height: 1.45;
  font-size: 14px;
}

.portal-section {
  margin-top: 18px;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(320px, .95fr);
  gap: 16px;
}

.portal-panel {
  border: 1px solid var(--portal-line);
  border-radius: 8px;
  background: var(--portal-panel);
  backdrop-filter: blur(16px);
  padding: 16px;
}

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

.portal-panel h3 {
  margin: 0;
  font-size: 18px;
}

.portal-board-list, .portal-record-list {
  display: grid;
  gap: 8px;
  max-height: 360px;
  overflow: auto;
}

@media (min-width: 981px) {
  .portal-section .portal-panel {
    display: flex;
    flex-direction: column;
    min-height: 0;
  }

  .portal-section .portal-record-list {
    flex: 1;
    min-height: 0;
    max-height: 490px;
  }
}

.portal-board-list {
  transition: opacity .14s ease;
}

.portal-board-list.is-loading {
  opacity: .62;
  pointer-events: none;
}

.portal-load-more {
  width: 100%;
  margin-top: 10px;
}

.portal-load-more[hidden] { display: none; }

.portal-pagination {
  display: grid;
  grid-template-columns: 88px 1fr 88px;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}

.portal-pagination span {
  color: var(--portal-muted);
  font-size: 13px;
  font-weight: 800;
  text-align: center;
}

.portal-pagination .portal-btn {
  min-height: 38px;
}

.portal-btn:disabled {
  cursor: default;
  opacity: .42;
}

/* 카드형 게임 시작 화면에서도 항상 보이는 게임허브 통로 */
.portal-home-bright {
  position: relative;
  z-index: 45;
  border: 1px solid rgba(143,203,255,.72) !important;
  background: linear-gradient(135deg,#3f92f4,#2564c9) !important;
  color: #fff !important;
  box-shadow: 0 5px 16px rgba(31,111,229,.34) !important;
  opacity: 1 !important;
  filter: none !important;
  text-shadow: 0 1px 3px rgba(0,0,0,.28);
}
.portal-home-bright:hover { background: linear-gradient(135deg,#58a7ff,#3274dd) !important; }

.portal-list-row {
  border: 1px solid rgba(255,255,255,.10);
  border-radius: 8px;
  padding: 10px 11px;
  background: rgba(255,255,255,.045);
}

.portal-list-row strong { color: #fff; }
.portal-list-row small { color: var(--portal-muted); }
.portal-board-row-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.portal-board-row-head > div:first-child { min-width: 0; }
.portal-board-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 5px;
}
.portal-board-actions button {
  min-height: 27px;
  padding: 4px 8px;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 7px;
  background: rgba(255,255,255,.08);
  color: #cbd7e9;
  cursor: pointer;
  font: 800 11px/1 Inter, system-ui, "Malgun Gothic", sans-serif;
}
.portal-board-actions button[data-board-action="delete"] { color: #ffb7b7; }
.portal-board-actions button.confirming { border-color: rgba(255,104,104,.7); background: rgba(185,35,35,.34); color: #fff; }
.portal-board-actions button:hover { background: rgba(255,255,255,.15); color: #fff; }
.portal-board-actions button:disabled { cursor: default; opacity: .45; }
.portal-board-editor { display: grid; gap: 7px; margin-top: 8px; }
.portal-board-editor textarea {
  width: 100%;
  min-height: 64px;
  resize: vertical;
  padding: 9px 10px;
  border: 1px solid rgba(91,156,255,.55);
  border-radius: 8px;
  outline: 0;
  background: rgba(4,10,23,.78);
  color: #eef5ff;
  font: 14px/1.45 Inter, system-ui, "Malgun Gothic", sans-serif;
}
.portal-board-editor textarea:focus { box-shadow: 0 0 0 3px rgba(58,132,255,.16); }
.portal-board-editor > div { display: flex; justify-content: flex-end; gap: 6px; }
.portal-board-editor button {
  min-height: 30px;
  padding: 5px 12px;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 7px;
  background: rgba(255,255,255,.09);
  color: #fff;
  cursor: pointer;
  font: 800 12px/1 Inter, system-ui, "Malgun Gothic", sans-serif;
}
.portal-board-editor button[data-board-action="save-edit"] { background: #347fe8; }
.portal-list-row p {
  margin: 7px 0 0;
  color: #d8e2f2;
  word-break: break-word;
  line-height: 1.45;
}

.portal-compose {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.portal-textarea {
  resize: vertical;
  min-height: 74px;
}

.portal-floating-bar {
  position: static;
  top: 12px;
  left: 12px;
  z-index: 100000;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 8px;
  background: rgba(8, 13, 27, .78);
  backdrop-filter: blur(14px);
  box-shadow: 0 10px 30px rgba(0,0,0,.28);
  font-family: Inter, system-ui, "Malgun Gothic", sans-serif;
}

.portal-floating-bar a, .portal-floating-bar button {
  color: #eef4ff;
  background: rgba(255,255,255,.09);
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 8px;
  min-height: 34px;
  padding: 0 10px;
  text-decoration: none;
  cursor: pointer;
  font: 800 13px/1 Inter, system-ui, "Malgun Gothic", sans-serif;
}

.portal-nick-display {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 8px;
  background: rgba(0,0,0,.24);
  color: #fff;
  padding: 0 10px;
  font: 800 13px/1 Inter, system-ui, "Malgun Gothic", sans-serif;
}

@media (max-width: 980px) {
  .portal-top, .portal-section { grid-template-columns: 1fr; }
  .portal-actions { grid-template-columns: 64px auto; justify-content: end; }
  .portal-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .portal-shell { width: min(100% - 20px, 1180px); padding-top: 16px; }
  .portal-actions { grid-template-columns: 56px auto; justify-content: start; }
  .portal-nick .portal-input { width: 116px; }
  body.portal-home .portal-grid {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 10px !important;
  }
  body.portal-home .game-tile {
    min-width: 0 !important;
    min-height: 0 !important;
  }
  body.portal-home .game-ribbon {
    top: 8px;
    left: 8px;
    min-width: 82px;
    min-height: 25px;
    padding-inline: 8px 9px;
    font-size: 11px;
  }
  body.portal-home .portal-grid-ad {
    grid-column: 1 / -1;
    width: 100%;
    padding-inline: 6px;
  }
  body.portal-home .tile-media {
    height: auto !important;
    aspect-ratio: 16 / 9;
    background: rgba(5, 10, 22, .92);
    display: grid;
    place-items: center;
  }
  body.portal-home .tile-media img {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain !important;
    object-position: center center !important;
  }
  body.portal-home .bumperball-media img {
    width: 88% !important;
    height: 88% !important;
  }
  body.portal-home .rocket-media .rocket-sky {
    position: absolute;
    object-fit: cover !important;
  }
  body.portal-home .rocket-media .rocket-ship {
    position: absolute;
    width: 135px !important;
    height: 72px !important;
    object-fit: contain !important;
  }
  body.portal-home .tile-body {
    padding: 10px 10px 12px;
    gap: 5px;
  }
  body.portal-home .tile-kicker { font-size: 11px; }
  body.portal-home .tile-body h2 { font-size: 19px; }
  body.portal-home .tile-body p {
    font-size: 12px;
    line-height: 1.45;
  }
  .portal-floating-bar {
    right: 8px;
    left: 8px;
    top: 8px;
  }
  .portal-floating-bar input { flex: 1; width: 0; }
}

.portal-btn.qr{min-width:44px;padding:0 10px;background:rgba(255,255,255,.10)}
.portal-qr-modal{position:fixed;inset:0;z-index:200000;display:none;place-items:center;background:rgba(2,6,23,.72);backdrop-filter:blur(12px);padding:20px}
.portal-qr-modal.show{display:grid}
.portal-qr-card{position:relative;width:min(560px,96vw);min-height:min(560px,96vw);display:grid;place-items:center;border:1px solid rgba(255,255,255,.18);border-radius:8px;background:#fff;padding:30px;box-shadow:0 30px 90px rgba(0,0,0,.45)}
.portal-qr-card img{width:min(500px,82vw);height:min(500px,82vw);display:block;image-rendering:pixelated}
.portal-qr-close{position:absolute;right:10px;top:10px;width:34px;height:34px;border:0;border-radius:8px;background:#111827;color:#fff;font-size:24px;line-height:1;cursor:pointer}
.portal-home-inline{height:34px;min-width:44px;padding:0 12px;border:1px solid rgba(255,255,255,.18);border-radius:8px;background:rgba(255,255,255,.10);color:inherit;text-decoration:none;display:inline-flex;align-items:center;justify-content:center;font:800 13px/1 Inter,system-ui,"Malgun Gothic",sans-serif;box-shadow:0 8px 20px rgba(0,0,0,.18);flex:0 0 auto}
.portal-home-inline.fallback{position:fixed;left:12px;top:12px;z-index:100000;color:#eef4ff;background:rgba(8,13,27,.78);backdrop-filter:blur(14px)}
.portal-nick-edit{height:34px;min-width:44px;padding:0 10px;border:1px solid rgba(255,255,255,.18);border-radius:8px;background:rgba(255,255,255,.10);color:inherit;display:inline-flex;align-items:center;justify-content:center;gap:4px;cursor:pointer;font:800 13px/1 Inter,system-ui,"Malgun Gothic",sans-serif;box-shadow:0 8px 20px rgba(0,0,0,.18);flex:0 0 auto}
.portal-nick-edit.fallback{position:fixed;left:12px;top:54px;z-index:100000;color:#eef4ff;background:rgba(8,13,27,.78);backdrop-filter:blur(14px)}
.portal-nick-modal{position:fixed;inset:0;z-index:210000;display:none;place-items:center;padding:20px;background:rgba(2,6,23,.76);backdrop-filter:blur(12px)}
.portal-nick-modal.show{display:grid}
.portal-nick-card{width:min(360px,calc(100vw - 32px));padding:24px;border:1px solid rgba(255,255,255,.18);border-radius:18px;background:#182338;color:#eef4ff;text-align:center;box-shadow:0 24px 70px rgba(0,0,0,.5);font-family:Inter,system-ui,"Malgun Gothic",sans-serif}
.portal-nick-card h2{margin:0 0 8px;font-size:22px;color:#f7c948}
.portal-nick-card p{margin:0 0 16px;color:#c6d1e3;font-size:13px;line-height:1.5}
.portal-nick-modal-input{width:100%;height:50px;border:2px solid rgba(79,140,255,.8);border-radius:12px;background:#fff;color:#172033;text-align:center;font:800 20px/1 Inter,system-ui,"Malgun Gothic",sans-serif;outline:none}
.portal-nick-modal-input:focus{border-color:#f7c948;box-shadow:0 0 0 4px rgba(247,201,72,.17)}
.portal-nick-actions{display:grid;grid-template-columns:1fr 1fr;gap:9px;margin-top:14px}
.portal-nick-actions button{height:44px;border:1px solid rgba(255,255,255,.16);border-radius:11px;background:rgba(255,255,255,.10);color:#fff;cursor:pointer;font:800 14px/1 Inter,system-ui,"Malgun Gothic",sans-serif}
.portal-nick-actions button.primary{border-color:transparent;background:linear-gradient(90deg,#4f8cff,#36d399)}
@media(max-width:420px){.portal-nick-edit span{display:none}.portal-nick-edit{padding:0 8px}}
