:root {
  --aspect-ratio: calc(432 / 304);
  --inverse-aspect-ratio: calc(304 / 432);
  --canvas-width: min(864px, 94vw);
  --canvas-height: calc(var(--canvas-width) * var(--inverse-aspect-ratio));
  --font-size: 15px;
  --btn-width: min(
    calc(6 * var(--font-size)),
    calc((var(--canvas-width) - 30px) / 4)
  );
  --btn-height: 38px;
  --ink: #163552;
  --muted: #567d97;
  --accent: #1681c9;
  --gold: #ffc65b;
}

:root {
  --background-color: #d8f3ff;
  --color: #163552;
  --link-color: #1681c9;
  --link-hover-color: #0e5b92;
  --btn-color: #234f72;
  --btn-background-color: #eaf6ff;
  --btn-in-dropdown-background-color: #f5fbff;
  --btn-in-dropdown-hover-background-color: #e0f3ff;
  --button-disabled-background-color: #cccccc;
  --update-fade-in-box-background-color: rgba(245, 251, 255, 0.95);
  --amount-to-invert-image: 0;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: 'Pretendard', 'Noto Sans KR', 'Malgun Gothic', system-ui, sans-serif;
  background: linear-gradient(150deg, #d8f3ff, #b6ddeb 60%, #94cbdf);
  min-height: 100vh;
}

/* Blue Island Topbar & Navigation */
.topbar {
  height: 72px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 4.3%;
  background: #f5fbfff0;
  border-bottom: 1px solid #fff9;
  gap: 16px;
  box-shadow: 0 2px 15px rgba(68,117,147,0.06);
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  text-decoration: none;
}
.brandmark {
  font-size: 36px;
  color: #238fce;
  text-shadow: 0 3px #075587;
  transform: rotate(-8deg);
  display: inline-block;
}
.brand b {
  font-size: 20px;
  letter-spacing: -0.8px;
}
.brand small {
  display: block;
  font-size: 9px;
  letter-spacing: 2px;
  color: #65859d;
  margin-top: 2px;
}
.toptools {
  display: flex;
  align-items: center;
  gap: 15px;
}
.public-label {
  font-size: 12px;
  font-weight: 700;
  color: #54778e;
}
.public-label:before {
  content: '';
  display: inline-block;
  width: 7px;
  height: 7px;
  background: #33af89;
  border-radius: 50%;
  margin-right: 7px;
}
.quiet {
  border: 1px solid #b0d2e7;
  border-radius: 8px;
  background: #eaf6ff;
  color: #234f72;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s;
}
.quiet:hover {
  background: #d9eeff;
}
.game-select {
  display: flex;
  gap: 8px;
  justify-content: center;
  padding: 10px 18px;
  background: #edf8fff2;
  border-bottom: 1px solid #a7cee5;
  overflow-x: auto;
}
.game-select a {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 18px;
  min-height: 40px;
  color: #3c6580;
  text-decoration: none;
  font: 750 14px system-ui, sans-serif;
  border: 1px solid transparent;
  border-radius: 9px;
  white-space: nowrap;
}
.game-select a:hover {
  background: #d9eefd;
}
.game-select a[aria-current=page] {
  color: #fff;
  background: #176fa9;
  border-color: #0f6199;
  box-shadow: 0 3px 0 #114b75;
}
.game-select a span {
  font-size: 17px;
}

main.page-main {
  max-width: 1100px;
  margin: auto;
  padding: 22px 20px 40px;
}

.intro {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}
.eyebrow {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 2px;
  color: #347ca6;
}
.intro h1 {
  font-size: 27px;
  letter-spacing: -1px;
  margin: 5px 0 0;
  font-weight: 850;
  color: var(--ink);
}
.intro h1 span {
  font-size: 13px;
  font-weight: 500;
  color: #587b94;
  margin-left: 12px;
}
.game-badge {
  font-size: 12px;
  font-weight: 750;
  border: 1px solid #fff9;
  border-radius: 20px;
  background: #f4fbffb8;
  padding: 7px 14px;
  box-shadow: 0 1px 6px rgba(10,50,80,0.06);
  color: var(--ink);
}

/* Cabinet Container */
.cabinet-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px;
  background: linear-gradient(150deg, #428fc7, #1667ac 52%, #164e86);
  border: 1px solid #2278b5;
  border-top: 2px solid #a8dbff;
  border-radius: 17px;
  box-shadow: 0 6px 0 #0e467d, 0 8px 0 rgba(197,237,255,0.45), 0 23px 40px rgba(16,76,139,0.25);
  margin: 0 auto;
  max-width: fit-content;
}

#flex-container {
  position: relative;
  display: flex;
  flex-direction: column;
  flex-wrap: nowrap;
  justify-content: center;
  align-items: center;
  width: auto;
  height: auto;
  margin: 0 auto;
  padding: 0;
}

#menu-bar {
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  width: var(--canvas-width);
  height: var(--btn-height);
  margin-bottom: 10px;
}

#game-dropdown-btn,
#options-dropdown-btn,
#about-btn,
.btn-container.right {
  display: none !important;
}

.btn-container {
  display: flex;
  align-items: center;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 34px;
  padding: 0 14px;
  border-radius: 8px;
  border: 1px solid #b0d2e7;
  background: #eaf6ff;
  color: #234f72;
  font-weight: 750;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}
.btn:hover {
  background: #d9eeff;
}
.btn:active {
  transform: translateY(1px);
}
.btn.glow {
  background: linear-gradient(#ffd171, #f6b143);
  border: 1px solid #ffe0a1;
  box-shadow: 0 3px #b77925;
  color: #664314;
}

.relative-container {
  position: relative;
  margin-right: 6px;
}

.dropdown, .submenu {
  position: absolute;
  z-index: 1000;
  background: #f5fbff;
  border: 1px solid #d1e6f3;
  border-radius: 12px;
  box-shadow: 0 16px 48px rgba(12,78,116,0.18);
  padding: 6px;
  min-width: 140px;
  display: none;
}
.dropdown.show, .submenu.show {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.dropdown .btn, .submenu .btn {
  background: transparent;
  color: var(--ink);
  border: none;
  border-radius: 6px;
  width: 100%;
  justify-content: flex-start;
  padding: 6px 10px;
  height: 32px;
  font-size: 12px;
}
.dropdown .btn:hover, .submenu .btn:hover {
  background: #e0f3ff;
}
.check {
  display: inline-block;
  width: 16px;
  font-weight: bold;
  color: #1681c9;
}

#game-canvas-container {
  position: relative;
  width: var(--canvas-width);
  height: var(--canvas-height);
  border: 3px solid #072a4b;
  border-radius: 10px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.2), 0 0 0 2px #2373ad;
  overflow: hidden;
  background: #000;
}

#game-canvas {
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  display: block;
}

.fade-in-box {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background: rgba(245, 251, 255, 0.95);
  color: var(--ink);
  z-index: 100;
  padding: 20px;
  overflow-y: auto;
}
.fade-in-box.hidden {
  display: none !important;
}
.fade-in-box h1 {
  font-size: 26px;
  margin: 0 0 10px;
  color: var(--ink);
}
.fade-in-box p {
  font-size: 13px;
  line-height: 1.7;
  color: #567d97;
}

.btn-in-box {
  border: 1px solid #ffe0a1;
  border-radius: 8px;
  background: linear-gradient(#ffd171, #f6b143);
  box-shadow: 0 3px #b77925;
  color: #664314;
  padding: 8px 18px;
  font-weight: 800;
  font-size: 13px;
  cursor: pointer;
}
.btn-in-box:hover {
  filter: brightness(1.05);
}

.toggle-switch {
  display: none;
}

kbd {
  font: 700 11px ui-monospace, Consolas, monospace;
  display: inline-block;
  padding: 3px 6px;
  min-width: 20px;
  text-align: center;
  background: #fff;
  border: 1px solid #c6d8e5;
  border-bottom: 2px solid #b3c9d9;
  border-radius: 4px;
  color: #42647e;
}
