/* ===================================
   LightCraft - スタイルシート
   =================================== */

/* リセットとグローバル */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    overflow: hidden;
    background: #000;
    font-family: 'Outfit', sans-serif;
    cursor: default;
    user-select: none;
}

/* ゲームキャンバス */
#game-canvas {
    display: block;
    width: 100vw;
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
}

/* ===================================
   スタート画面
   =================================== */
#start-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0a1628 0%, #1a2a4a 30%, #2d4a3e 60%, #1a3a2a 100%);
    cursor: pointer;
}

#start-screen::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(circle at 20% 30%, rgba(76, 175, 80, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 70%, rgba(33, 150, 243, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.02) 0%, transparent 70%);
    animation: bgPulse 8s ease-in-out infinite alternate;
}

@keyframes bgPulse {
    0% { opacity: 0.5; }
    100% { opacity: 1; }
}

.start-content {
    text-align: center;
    z-index: 1;
    animation: fadeInUp 1s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.game-title {
    font-family: 'Outfit', sans-serif;
    font-weight: 900;
    font-size: clamp(3rem, 10vw, 7rem);
    letter-spacing: 4px;
    margin-bottom: 0.5rem;
    text-shadow: 
        0 0 40px rgba(76, 175, 80, 0.4),
        0 4px 8px rgba(0, 0, 0, 0.5);
}

.game-title span {
    display: inline-block;
    animation: titleBounce 2s ease-in-out infinite;
}

.title-l { color: #4CAF50; animation-delay: 0s; }
.title-i { color: #66BB6A; animation-delay: 0.1s; }
.title-g { color: #81C784; animation-delay: 0.2s; }
.title-h { color: #A5D6A7; animation-delay: 0.3s; }
.title-t1 { color: #81C784; animation-delay: 0.4s; }
.title-c { color: #FFB74D; animation-delay: 0.5s; }
.title-r { color: #FFA726; animation-delay: 0.6s; }
.title-a { color: #FF9800; animation-delay: 0.7s; }
.title-f { color: #FB8C00; animation-delay: 0.8s; }
.title-t2 { color: #F57C00; animation-delay: 0.9s; }

@keyframes titleBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

.start-subtitle {
    font-size: 1.3rem;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 2.5rem;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; }
}

.controls-info {
    display: flex;
    gap: 2rem;
    justify-content: center;
    flex-wrap: wrap;
}

.control-group {
    background: rgba(255, 255, 255, 0.06);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 1.5rem 2rem;
    min-width: 260px;
}

.control-group h3 {
    color: rgba(255, 255, 255, 0.9);
    font-size: 1rem;
    margin-bottom: 1rem;
    font-weight: 600;
}

.control-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.6rem;
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.65);
}

.control-row span {
    margin-left: auto;
}

kbd {
    display: inline-block;
    padding: 3px 8px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    color: #e0e0e0;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    min-width: 28px;
    text-align: center;
}

/* ===================================
   ポーズ画面
   =================================== */
#pause-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 90;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    cursor: pointer;
}

.pause-content {
    text-align: center;
    color: white;
}

.pause-content h2 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
}

.pause-content p {
    font-size: 1.2rem;
    opacity: 0.7;
}

/* ===================================
   HUD
   =================================== */
#hud {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 50;
}

/* クロスヘア */
#crosshair {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 24px;
    height: 24px;
}

.crosshair-h,
.crosshair-v {
    position: absolute;
    background: rgba(255, 255, 255, 0.85);
    border-radius: 1px;
}

.crosshair-h {
    width: 24px;
    height: 2px;
    top: 50%;
    left: 0;
    transform: translateY(-50%);
}

.crosshair-v {
    width: 2px;
    height: 24px;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
}

/* ホットバー */
#hotbar {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 4px;
    padding: 6px;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
}

.hotbar-slot {
    width: 52px;
    height: 52px;
    background: rgba(255, 255, 255, 0.06);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: all 0.15s ease;
}

.hotbar-slot.active {
    border-color: rgba(255, 255, 255, 0.9);
    background: rgba(255, 255, 255, 0.12);
    box-shadow: 0 0 12px rgba(255, 255, 255, 0.2), inset 0 0 8px rgba(255, 255, 255, 0.05);
}

.hotbar-block {
    width: 28px;
    height: 28px;
    border-radius: 4px;
    border: 1px solid rgba(0, 0, 0, 0.3);
}

.hotbar-key {
    position: absolute;
    top: 2px;
    left: 4px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.6rem;
    color: rgba(255, 255, 255, 0.45);
}

.hotbar-name {
    font-size: 0.55rem;
    color: rgba(255, 255, 255, 0.6);
    margin-top: 2px;
    white-space: nowrap;
}

/* 情報パネル */
#info-panel {
    position: absolute;
    top: 12px;
    left: 12px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.7);
    background: rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(4px);
    padding: 8px 12px;
    border-radius: 8px;
    line-height: 1.6;
}

/* ===================================
   ローディング画面
   =================================== */
#loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #0a1628;
    color: white;
    flex-direction: column;
}

.loading-content {
    text-align: center;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(255, 255, 255, 0.15);
    border-top-color: #4CAF50;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 1.5rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-content p {
    font-size: 1.1rem;
    margin-bottom: 1.5rem;
    opacity: 0.8;
}

.loading-bar-container {
    width: 300px;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
    margin: 0 auto;
}

.loading-bar {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, #4CAF50, #81C784);
    border-radius: 3px;
    transition: width 0.3s ease;
}

/* ===================================
   ユーティリティ
   =================================== */
/* 視点モード表示 */
#view-mode {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -70%);
    font-size: 1.1rem;
    color: rgba(255, 255, 255, 0.9);
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(4px);
    padding: 8px 20px;
    border-radius: 8px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

#view-mode.view-mode-fade {
    animation: viewModeFade 2s ease forwards;
}

@keyframes viewModeFade {
    0% { opacity: 1; }
    60% { opacity: 1; }
    100% { opacity: 0; }
}

/* ===================================
   インベントリ画面
   =================================== */
#inventory-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 80;
    display: flex;
    align-items: center;
    justify-content: center;
}

.inventory-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(6px);
}

.inventory-container {
    position: relative;
    z-index: 1;
    background: linear-gradient(145deg, rgba(30, 30, 40, 0.95), rgba(20, 20, 30, 0.98));
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 16px;
    padding: 24px 28px;
    min-width: 520px;
    max-width: 680px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.6),
        0 0 40px rgba(76, 175, 80, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.06);
    animation: invSlideIn 0.2s ease-out;
}

@keyframes invSlideIn {
    from {
        opacity: 0;
        transform: scale(0.92) translateY(20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.inventory-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.inventory-title {
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    font-size: 1.3rem;
    color: rgba(255, 255, 255, 0.92);
    letter-spacing: 1px;
}

.inventory-close-hint {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.4);
}

.inventory-close-hint kbd {
    padding: 2px 6px;
    font-size: 0.65rem;
}

/* ブロックグリッド */
.inventory-grid {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    gap: 5px;
    margin-bottom: 16px;
}

.inv-item {
    aspect-ratio: 1;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    background: rgba(255, 255, 255, 0.04);
    border: 2px solid rgba(255, 255, 255, 0.06);
    cursor: pointer;
    transition: all 0.12s ease;
    position: relative;
    overflow: hidden;
}

.inv-item:hover {
    border-color: rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.08);
    transform: scale(1.06);
    z-index: 2;
}

.inv-item.inv-selected {
    border-color: #4CAF50;
    background: rgba(76, 175, 80, 0.15);
    box-shadow: 0 0 12px rgba(76, 175, 80, 0.3), inset 0 0 8px rgba(76, 175, 80, 0.1);
}

.inv-item .inv-block {
    width: 32px;
    height: 32px;
    border-radius: 4px;
    border: 1px solid rgba(0, 0, 0, 0.3);
    box-shadow: inset 0 -2px 4px rgba(0, 0, 0, 0.2);
}

.inv-item .inv-name {
    font-size: 0.48rem;
    color: rgba(255, 255, 255, 0.55);
    margin-top: 3px;
    text-align: center;
    line-height: 1.1;
    max-width: 100%;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    padding: 0 2px;
}

/* ホバー時にツールチップ表示 */
.inv-item::after {
    content: attr(data-name);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.88);
    color: rgba(255, 255, 255, 0.95);
    font-size: 0.7rem;
    padding: 4px 10px;
    border-radius: 6px;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease;
    z-index: 10;
}

.inv-item:hover::after {
    opacity: 1;
}

/* セパレーター */
.inventory-separator {
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.15), transparent);
    margin: 4px 0 12px;
}

.inventory-subtitle {
    font-family: 'Outfit', sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.75);
    margin-bottom: 10px;
}

.inventory-subtitle-hint {
    font-weight: 400;
    font-size: 0.65rem;
    color: rgba(255, 255, 255, 0.35);
    margin-left: 8px;
}

/* インベントリ内ホットバー */
.inventory-hotbar {
    display: flex;
    gap: 5px;
    justify-content: center;
}

.inv-hotbar-slot {
    width: 52px;
    height: 52px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    background: rgba(255, 255, 255, 0.04);
    border: 2px solid rgba(255, 255, 255, 0.1);
    cursor: pointer;
    transition: all 0.12s ease;
    position: relative;
}

.inv-hotbar-slot:hover {
    border-color: rgba(255, 255, 255, 0.35);
    background: rgba(255, 255, 255, 0.08);
}

.inv-hotbar-slot.inv-slot-active {
    border-color: rgba(255, 255, 255, 0.9);
    background: rgba(255, 255, 255, 0.1);
}

.inv-hotbar-slot.inv-slot-target {
    border-color: #FFB74D;
    background: rgba(255, 183, 77, 0.12);
    box-shadow: 0 0 10px rgba(255, 183, 77, 0.25);
}

.inv-hotbar-slot .inv-slot-key {
    position: absolute;
    top: 2px;
    left: 4px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.55rem;
    color: rgba(255, 255, 255, 0.4);
}

.inv-hotbar-slot .inv-slot-block {
    width: 28px;
    height: 28px;
    border-radius: 4px;
    border: 1px solid rgba(0, 0, 0, 0.3);
}

/* マウス追従ブロック */
#held-block {
    position: fixed;
    width: 36px;
    height: 36px;
    border-radius: 6px;
    border: 2px solid rgba(255, 255, 255, 0.6);
    pointer-events: none;
    z-index: 200;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
    transform: translate(-50%, -50%);
    animation: heldPulse 1.2s ease-in-out infinite alternate;
}

@keyframes heldPulse {
    0% { box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5), 0 0 0 rgba(76, 175, 80, 0); }
    100% { box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5), 0 0 10px rgba(76, 175, 80, 0.4); }
}

.hidden {
    display: none !important;
}
