:root {
  --bg-color: #eaedf1;
  --panel-bg: #ffffff;
  --frame-bg: #bdbdbd;
  --border-light: #ffffff;
  --border-dark: #737373;
  --border-darker: #333333;
  --tile-bg: #c0c0c0;
  --tile-revealed: #dcdcdc;
  --primary-color: #1976d2;
  --text-main: #212529;
  --text-muted: #6c757d;
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono-font: "Consolas", "Courier New", monospace;
  --box-shadow: none;
  --cell-radius: 0px;
  --counter-bg: #000000;
  --counter-color: #ff0000;
  --frame-radius: 0px;
  --cell-size: 32px;
  --cell-font: 18px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  width: 100vw;
  height: 100vh;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

body {
  background-color: var(--bg-color);
  color: var(--text-main);
  font-family: var(--font-family);
  display: flex;
  transition: background-color 0.25s ease;
}

/* =========================================
   브라우저 100% 가득 채우는 풀사이즈 컨테이너
   ========================================= */
.app-container {
  width: 100vw;
  height: 100vh;
  background: var(--panel-bg);
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-sizing: border-box;
  overflow: hidden;
  transition: all 0.25s ease;
}

/* =========================================
   1. 단일 행 상단 통합 바 (Single Row Top Bar)
   ========================================= */
.unified-top-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f8f9fa;
  border: 1px solid #dee2e6;
  border-radius: 6px;
  padding: 5px 8px;
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: thin;
  flex-shrink: 0;
}

.brand-zone {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

.brand-icon {
  font-size: 1.15rem;
}

.brand-name {
  font-size: 0.98rem;
  font-weight: 800;
  white-space: nowrap;
}

.bar-divider {
  width: 1px;
  height: 18px;
  background: #ced4da;
  flex-shrink: 0;
}

/* 게임 단계 버튼 */
.tier-zone {
  display: flex;
  background: #e9ecef;
  border-radius: 5px;
  padding: 2px;
  gap: 2px;
  flex-shrink: 0;
}

.tier-btn {
  border: none;
  background: transparent;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  color: #495057;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.tier-btn.active {
  background: #ffffff;
  color: #1976d2;
  font-weight: 700;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
}

/* 레벨 버튼 */
.level-zone {
  display: flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
}

.zone-label {
  font-size: 0.74rem;
  font-weight: 700;
  color: #6c757d;
  margin-right: 1px;
  white-space: nowrap;
}

.level-btns {
  display: flex;
  gap: 2px;
}

.lvl-btn {
  width: 25px;
  height: 25px;
  border: 1px solid #ced4da;
  background: #ffffff;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 700;
  color: #343a40;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.lvl-btn.active {
  background: #0284c7;
  color: #ffffff;
  border-color: #0369a1;
  box-shadow: 0 1px 2px rgba(2, 132, 199, 0.35);
}

/* 스킨 선택 존 */
.skin-zone {
  display: flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
}

.skin-btns {
  display: flex;
  gap: 2px;
  background: #e9ecef;
  padding: 2px;
  border-radius: 4px;
}

.skin-btn {
  border: none;
  background: transparent;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 0.76rem;
  font-weight: 600;
  color: #495057;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.skin-btn:hover {
  background: rgba(255, 255, 255, 0.7);
}

.skin-btn.active {
  background: #ffffff;
  color: #212529;
  font-weight: 800;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

/* 정보 배지 */
.info-badge {
  font-size: 0.78rem;
  font-weight: 600;
  color: #495057;
  background: #e9ecef;
  padding: 3px 7px;
  border-radius: 4px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* 우측 액션 */
.action-zone {
  display: flex;
  gap: 3px;
  margin-left: auto;
  flex-shrink: 0;
}

.action-btn {
  width: 28px;
  height: 27px;
  border: 1px solid #ced4da;
  background: #ffffff;
  border-radius: 4px;
  font-size: 0.92rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.action-btn.active-flag {
  background: #fee2e2;
  border-color: #ef4444;
}

/* 창 데코 바 */
.window-decor-bar {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 4px 8px;
  flex-shrink: 0;
}

.decor-left {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.82rem;
  font-weight: 700;
}

.decor-controls {
  display: flex;
  gap: 4px;
}

.decor-btn {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  display: inline-block;
  cursor: pointer;
}

/* =========================================
   2. 게임 보드 영역 (화면 전체 꽉 차도록 확장)
   ========================================= */
.game-wrapper {
  flex: 1;
  width: 100%;
  height: 100%;
  min-height: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  padding: 2px;
  background: #e9ecef;
  border-radius: 6px;
  box-sizing: border-box;
  transition: all 0.25s ease;
}

.minesweeper-box {
  background: var(--frame-bg);
  border: 3px solid;
  border-color: var(--border-light) var(--border-dark) var(--border-dark) var(--border-light);
  border-radius: var(--frame-radius);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
  max-width: 100%;
  max-height: 100%;
  box-sizing: border-box;
  transition: all 0.25s ease;
}

.ms-header {
  background: var(--frame-bg);
  border: 3px solid;
  border-color: var(--border-dark) var(--border-light) var(--border-light) var(--border-dark);
  padding: 4px 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.digital-display {
  background: var(--counter-bg);
  color: var(--counter-color);
  font-family: var(--mono-font);
  font-size: 1.6rem;
  font-weight: bold;
  letter-spacing: 2px;
  padding: 2px 6px;
  border: 2px solid;
  border-color: var(--border-darker) #888 #888 var(--border-darker);
  min-width: 60px;
  text-align: right;
  line-height: 1;
}

.face-btn {
  width: 38px;
  height: 38px;
  font-size: 1.5rem;
  background: var(--frame-bg);
  border: 3px solid;
  border-color: var(--border-light) var(--border-dark) var(--border-dark) var(--border-light);
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  outline: none;
  transition: transform 0.05s;
}

.face-btn:active {
  border-color: var(--border-dark) var(--border-light) var(--border-light) var(--border-dark);
  transform: translate(1px, 1px);
}

.board-viewport {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  border: 3px solid;
  border-color: var(--border-dark) var(--border-light) var(--border-light) var(--border-dark);
  background: #808080;
  box-sizing: border-box;
}

.ms-board {
  display: grid;
  background: #808080;
  padding: 1px;
  transform-origin: center center;
  transition: transform 0.1s ease-out;
}

/* 동적 반응형 타일 셀 */
.cell {
  width: var(--cell-size);
  height: var(--cell-size);
  background-color: var(--tile-bg);
  border: 3px solid;
  border-color: var(--border-light) var(--border-dark) var(--border-dark) var(--border-light);
  border-radius: var(--cell-radius);
  font-family: var(--mono-font);
  font-size: var(--cell-font);
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-sizing: border-box;
}

.cell:active:not(.revealed):not(.flagged) {
  border-width: 1px;
  border-color: #7b7b7b;
  background-color: var(--tile-revealed);
}

.cell.revealed {
  border: 1px solid #7b7b7b;
  background-color: var(--tile-revealed);
  cursor: default;
}

.cell.flagged {
  cursor: pointer;
}

.cell.mine-hit {
  background-color: #ff3333 !important;
  border: 1px solid #aa0000;
}

.cell.wrong-flag {
  background-color: #ffcccc;
  position: relative;
}

.cell.wrong-flag::after {
  content: '❌';
  font-size: 13px;
  position: absolute;
}

/* 숫자 색상표 */
.cell[data-val="1"] { color: #0000ff; }
.cell[data-val="2"] { color: #008000; }
.cell[data-val="3"] { color: #ff0000; }
.cell[data-val="4"] { color: #000080; }
.cell[data-val="5"] { color: #800000; }
.cell[data-val="6"] { color: #008080; }
.cell[data-val="7"] { color: #000000; }
.cell[data-val="8"] { color: #808080; }

.bottom-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.78rem;
  color: var(--text-muted);
  padding: 1px 4px;
  flex-shrink: 0;
}

.quick-tip {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.zoom-controls {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

.zoom-btn {
  width: 24px;
  height: 24px;
  border: 1px solid #ced4da;
  background: #ffffff;
  border-radius: 4px;
  cursor: pointer;
  font-weight: bold;
}

.game-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(33, 37, 41, 0.95);
  color: #fff;
  padding: 10px 20px;
  border-radius: 24px;
  font-weight: 600;
  font-size: 0.92rem;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
  z-index: 100;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.game-toast.hidden {
  opacity: 0;
  visibility: hidden;
}

.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.modal.hidden { display: none; }
.modal-content {
  background: #ffffff;
  border-radius: 10px;
  max-width: 480px;
  width: 90%;
  box-shadow: 0 10px 30px rgba(0,0,0,0.2);
  overflow: hidden;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid #dee2e6;
}
.close-btn {
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: #6c757d;
}
.modal-body {
  padding: 18px;
  font-size: 0.9rem;
  line-height: 1.6;
  color: #495057;
}
.modal-body ul { padding-left: 20px; margin: 6px 0 14px 0; }

/* ==========================================================================
   스킨 1: cuteline (이미지 1 참고)
   ========================================================================== */
body[data-theme="cuteline"] {
  --bg-color: #4ebfd3;
  --panel-bg: #fffcf4;
  --frame-bg: #ffeec8;
  --border-light: #fff8e8;
  --border-dark: #e0b47e;
  --border-darker: #42281a;
  --tile-bg: #fffaee;
  --tile-revealed: #ffe8bd;
  --text-main: #42281a;
  --counter-bg: #42281a;
  --counter-color: #ffbf47;
  --cell-radius: 5px;
  --frame-radius: 12px;
  background-image: radial-gradient(circle, rgba(255,255,255,0.25) 10%, transparent 11%);
  background-size: 20px 20px;
}

body[data-theme="cuteline"] .app-container {
  border: 3px solid #42281a;
  box-shadow: none;
}

body[data-theme="cuteline"] .unified-top-bar {
  background: #fff5e0;
  border: 2px solid #42281a;
  border-radius: 10px;
}

body[data-theme="cuteline"] .tier-zone,
body[data-theme="cuteline"] .skin-btns {
  background: #f7e0b5;
  border-radius: 6px;
}

body[data-theme="cuteline"] .tier-btn.active,
body[data-theme="cuteline"] .skin-btn.active {
  background: #ffa834;
  color: #ffffff;
  border: 1px solid #42281a;
}

body[data-theme="cuteline"] .lvl-btn {
  border: 1.5px solid #42281a;
  border-radius: 5px;
  background: #ffffff;
  color: #42281a;
}

body[data-theme="cuteline"] .lvl-btn.active {
  background: #4ebfd3;
  color: #ffffff;
  border-color: #42281a;
}

body[data-theme="cuteline"] .info-badge {
  background: #ffe3a8;
  border: 1.5px solid #42281a;
  color: #42281a;
}

body[data-theme="cuteline"] .window-decor-bar {
  display: flex;
  background: #ffa834;
  border: 2px solid #42281a;
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  color: #ffffff;
}

body[data-theme="cuteline"] .decor-controls .decor-btn {
  width: 13px;
  height: 13px;
  border-radius: 3px;
  border: 1.5px solid #42281a;
}
body[data-theme="cuteline"] .btn-min { background: #fee08b; }
body[data-theme="cuteline"] .btn-max { background: #8bd9e5; }
body[data-theme="cuteline"] .btn-close { background: #ff7575; }

body[data-theme="cuteline"] .game-wrapper {
  background: #5dcada;
  border: 2px solid #42281a;
  border-radius: 0 0 10px 10px;
}

body[data-theme="cuteline"] .minesweeper-box {
  background: #ffeec8;
  border: 3px solid #42281a;
  border-radius: 10px;
  box-shadow: 4px 4px 0px #382115;
}

body[data-theme="cuteline"] .ms-header {
  background: #fff5e0;
  border: 2px solid #42281a;
  border-radius: 6px;
}

body[data-theme="cuteline"] .board-viewport {
  border: 2px solid #42281a;
  border-radius: 6px;
  background: #e8d0a8;
}

body[data-theme="cuteline"] .ms-board {
  background: #e8d0a8;
  gap: 1px;
}

body[data-theme="cuteline"] .cell {
  background: #fffaee;
  border: 2px solid #42281a;
}

body[data-theme="cuteline"] .cell.revealed {
  background: #ffe8bd;
  border: 1px solid #d2a76f;
}

body[data-theme="cuteline"] .digital-display {
  border: 2px solid #42281a;
  border-radius: 5px;
}

body[data-theme="cuteline"] .face-btn {
  border: 2px solid #42281a;
  border-radius: 6px;
  background: #ffeec8;
}

/* ==========================================================================
   스킨 2: retro3.1 (이미지 2 참고)
   ========================================================================== */
body[data-theme="retro3.1"] {
  --bg-color: #008080;
  --panel-bg: #c0c0c0;
  --frame-bg: #c0c0c0;
  --border-light: #ffffff;
  --border-dark: #808080;
  --border-darker: #000000;
  --tile-bg: #c0c0c0;
  --tile-revealed: #c0c0c0;
  --counter-bg: #000000;
  --counter-color: #ff0000;
  --cell-radius: 0px;
  --frame-radius: 0px;
}

body[data-theme="retro3.1"] .app-container {
  border: 3px solid;
  border-color: #ffffff #000000 #000000 #ffffff;
}

body[data-theme="retro3.1"] .unified-top-bar {
  background: #c0c0c0;
  border: 2px solid;
  border-color: #808080 #ffffff #ffffff #808080;
  border-radius: 0;
}

body[data-theme="retro3.1"] .window-decor-bar {
  display: flex;
  background: #000080;
  color: #ffffff;
  border: 2px solid #000080;
  border-radius: 0;
}

body[data-theme="retro3.1"] .decor-controls .decor-btn {
  background: #c0c0c0;
  border: 1px solid;
  border-color: #ffffff #000000 #000000 #ffffff;
  width: 14px;
  height: 14px;
}
body[data-theme="retro3.1"] .btn-min::after { content: '▼'; font-size: 8px; color: #000; display: block; text-align: center; }
body[data-theme="retro3.1"] .btn-max::after { content: '▲'; font-size: 8px; color: #000; display: block; text-align: center; }

body[data-theme="retro3.1"] .tier-zone,
body[data-theme="retro3.1"] .skin-btns {
  background: #a0a0a0;
  border-radius: 0;
}

body[data-theme="retro3.1"] .tier-btn,
body[data-theme="retro3.1"] .skin-btn,
body[data-theme="retro3.1"] .lvl-btn {
  border-radius: 0;
  border: 2px solid;
  border-color: #ffffff #808080 #808080 #ffffff;
}

body[data-theme="retro3.1"] .tier-btn.active,
body[data-theme="retro3.1"] .skin-btn.active,
body[data-theme="retro3.1"] .lvl-btn.active {
  border-color: #808080 #ffffff #ffffff #808080;
  background: #000080;
  color: #ffffff;
}

body[data-theme="retro3.1"] .game-wrapper {
  background: #006666;
  border-radius: 0;
}

body[data-theme="retro3.1"] .cell {
  border: 3px solid;
  border-color: #ffffff #808080 #808080 #ffffff;
}

body[data-theme="retro3.1"] .cell.revealed {
  border: 1px solid #7b7b7b;
}

/* ==========================================================================
   스킨 3: retromac (이미지 3 참고)
   ========================================================================== */
body[data-theme="retromac"] {
  --bg-color: #cfb8ec;
  --panel-bg: #f5f2eb;
  --frame-bg: #eae5d9;
  --border-light: #ffffff;
  --border-dark: #b5ae9f;
  --border-darker: #000000;
  --tile-bg: #f8f6f0;
  --tile-revealed: #ded9cd;
  --text-main: #1a1a1a;
  --counter-bg: #dbe4d5;
  --counter-color: #243024;
  --cell-radius: 2px;
  --frame-radius: 4px;
  background-image: linear-gradient(45deg, #c4aadc 25%, transparent 25%), 
                    linear-gradient(-45deg, #c4aadc 25%, transparent 25%), 
                    linear-gradient(45deg, transparent 75%, #c4aadc 75%), 
                    linear-gradient(-45deg, transparent 75%, #c4aadc 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0px;
}

body[data-theme="retromac"] .app-container {
  border: 2px solid #000000;
  border-radius: 4px;
}

body[data-theme="retromac"] .unified-top-bar {
  background: #fbf9f4;
  border: 2px solid #000000;
  border-radius: 3px;
}

body[data-theme="retromac"] .window-decor-bar {
  display: flex;
  background: repeating-linear-gradient(
    0deg,
    #000000 0px,
    #000000 1px,
    #f5f2eb 1px,
    #f5f2eb 3px
  );
  border: 2px solid #000000;
  border-bottom: none;
  border-radius: 3px 3px 0 0;
  padding: 3px 6px;
}

body[data-theme="retromac"] .decor-left {
  background: #f5f2eb;
  padding: 1px 6px;
  border: 1px solid #000000;
  border-radius: 2px;
}

body[data-theme="retromac"] .decor-controls .btn-close {
  background: #f5f2eb;
  border: 1px solid #000000;
  width: 13px;
  height: 13px;
}

body[data-theme="retromac"] .tier-zone,
body[data-theme="retromac"] .skin-btns {
  background: #ded9cd;
  border: 1px solid #000000;
  border-radius: 2px;
}

body[data-theme="retromac"] .tier-btn.active,
body[data-theme="retromac"] .skin-btn.active {
  background: #000000;
  color: #ffffff;
}

body[data-theme="retromac"] .lvl-btn {
  border: 1.5px solid #000000;
  background: #fbf9f4;
  color: #000000;
}

body[data-theme="retromac"] .lvl-btn.active {
  background: #000000;
  color: #ffffff;
}

body[data-theme="retromac"] .game-wrapper {
  background: #bba4db;
  border: 2px solid #000000;
  border-radius: 0 0 3px 3px;
}

body[data-theme="retromac"] .minesweeper-box {
  background: #eae5d9;
  border: 2px solid #000000;
  box-shadow: 3px 3px 0px #000000;
}

body[data-theme="retromac"] .ms-header {
  background: #f5f2eb;
  border: 1.5px solid #000000;
}

body[data-theme="retromac"] .board-viewport {
  border: 2px solid #000000;
  background: #c8c2b4;
}

body[data-theme="retromac"] .cell {
  background: #f8f6f0;
  border: 1.5px solid #000000;
}

body[data-theme="retromac"] .cell.revealed {
  background: #ded9cd;
  border: 1px solid #999999;
}

body[data-theme="retromac"] .digital-display {
  border: 1.5px solid #000000;
}

body[data-theme="retromac"] .face-btn {
  border: 1.5px solid #000000;
  background: #f5f2eb;
}
